From 22e8c588324184b777cea9f55ec0fc73b56949b8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 15 Sep 2013 09:28:15 +0200 Subject: New experimental sample selector (enable using --with-experimental argument on ./configure). --- src/instrument.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/instrument.cc') diff --git a/src/instrument.cc b/src/instrument.cc index 7232431..3b357eb 100644 --- a/src/instrument.cc +++ b/src/instrument.cc @@ -34,6 +34,10 @@ #include "sample.h" #include "configuration.h" +#ifdef EXPERIMENTAL +#define NEW_ALGORITHM +#endif + Instrument::Instrument() { DEBUG(instrument, "new %p\n", this); @@ -62,6 +66,8 @@ bool Instrument::isValid() Sample *Instrument::sample(level_t level, size_t pos) { + Sample *sample = NULL; + if(Conf::enable_velocity_modifier == false) { mod = 1.0; lastpos = 0; @@ -81,24 +87,39 @@ 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(Conf::enable_velocity_modifier) { lastpos = pos; mod *= Conf::velocity_modifier_weight; } - return s[idx]; + return sample; } void Instrument::addSample(level_t a, level_t b, Sample *s) { samples.insert(a, b, s); +#ifdef NEW_ALGORITHM + powerlist.add(s); +#endif/*NEW_ALGORITHM*/ } +void Instrument::finalise() +{ +#ifdef NEW_ALGORITHM + powerlist.finalise(); +#endif/*NEW_ALGORITHM*/ +}} + std::string Instrument::name() { return _name; -- cgit v1.2.3