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. --- src/instrument.cc | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'src/instrument.cc') 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() -- cgit v1.2.3