From 64d8efa4f3abe4257120b85fb4d4a063d96edbfc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 25 Apr 2014 20:04:08 +0200 Subject: Use old 'velocity groups' algorithm on version 1.0 instruments and new 'power distribution' algorithm on 2.0 instruments. Remove 'with-experimental' option from configure. --- configure.ac | 6 ------ src/instrument.cc | 39 ++++++++++++++++++--------------------- src/instrument.h | 2 +- src/instrumentparser.cc | 14 +++++++------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index 58b4eac..b1de420 100644 --- a/configure.ac +++ b/configure.ac @@ -30,12 +30,6 @@ if test x$with_debug == xyes; then fi CXXFLAGS="$CXXFLAGS $HUGIN_PARM" -AC_ARG_WITH(experimental, [ --with-experimental Build with experimental features]) -if test x$with_experimental == xyes; then - AC_MSG_WARN([*** Building with experimental support!]) - CXXFLAGS="$CXXFLAGS -DEXPERIMENTAL" -fi - dnl =========================== dnl Check for GUI backend dnl =========================== diff --git a/src/instrument.cc b/src/instrument.cc index 8c88503..d0b25aa 100644 --- a/src/instrument.cc +++ b/src/instrument.cc @@ -34,10 +34,6 @@ #include "sample.h" #include "configuration.h" -#ifdef EXPERIMENTAL -#define NEW_ALGORITHM -#endif - Instrument::Instrument() { DEBUG(instrument, "new %p\n", this); @@ -88,15 +84,16 @@ Sample *Instrument::sample(level_t level, size_t pos) if(mod > 1.0) mod = 1.0; } -#ifdef NEW_ALGORITHM - sample = powerlist.get(level * mod); -#else - // printf("Find level %f\n", level); - std::vector s = samples.get(level * mod); - if(s.size() == 0) return NULL; - size_t idx = rand()%(s.size()); - sample = s[idx]; -#endif/*NEW_ALGORITHM*/ + if(version >= VersionStr("2.0")) { + // Version 2.0 + sample = powerlist.get(level * mod); + } else { + // Version 1.0 + std::vector s = samples.get(level * mod); + if(s.size() == 0) return NULL; + size_t idx = rand()%(s.size()); + sample = s[idx]; + } if(Conf::enable_velocity_modifier) { lastpos = pos; @@ -113,15 +110,15 @@ void Instrument::addSample(level_t a, level_t b, Sample *s) void Instrument::finalise() { -#ifdef NEW_ALGORITHM - std::vector::iterator s = samplelist.begin(); - while(s != samplelist.end()) { - powerlist.add(*s); - s++; + if(version >= VersionStr("2.0")) { + std::vector::iterator s = samplelist.begin(); + while(s != samplelist.end()) { + powerlist.add(*s); + s++; + } + + powerlist.finalise(); } - - powerlist.finalise(); -#endif/*NEW_ALGORITHM*/ } std::string Instrument::name() diff --git a/src/instrument.h b/src/instrument.h index b7ddeea..416b6c2 100644 --- a/src/instrument.h +++ b/src/instrument.h @@ -64,7 +64,7 @@ private: std::string _name; std::string _description; - VersionStr _version; + VersionStr version; RangeMap samples; PowerList powerlist; diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc index 3a07f1f..0889d74 100644 --- a/src/instrumentparser.cc +++ b/src/instrumentparser.cc @@ -60,14 +60,14 @@ void InstrumentParser::startTag(std::string name, if(attr.find("version") != attr.end()) { try { - instrument._version = VersionStr(attr["version"]); + instrument.version = VersionStr(attr["version"]); } catch(const char *err) { ERR(instrparser, "Error parsing version number: %s, using 1.0\n", err); - instrument._version = VersionStr(1,0,0); + instrument.version = VersionStr(1,0,0); } } else { WARN(instrparser, "Missing version number, assuming 1.0\n"); - instrument._version = VersionStr(1,0,0); + instrument.version = VersionStr(1,0,0); } } @@ -161,10 +161,10 @@ void InstrumentParser::startTag(std::string name, return; } -#ifndef EXPERIMENTAL - // TODO: Old algorithm needs this here. - instrument.addSample(lower, upper, sample); -#endif/*EXPERIMENTAL*/ + if(instrument.version == VersionStr("1.0")) { + // Old "velocity group" algorithm needs this + instrument.addSample(lower, upper, sample); + } } } -- cgit v1.2.3