summaryrefslogtreecommitdiff
path: root/src/instrument.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-09-15 09:28:15 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-09-15 09:28:15 +0200
commit22e8c588324184b777cea9f55ec0fc73b56949b8 (patch)
treecb75167772447848650d90b01c171b344cdc61e3 /src/instrument.cc
parent9883fb4fc232ebdea44dcf7b015499d31f999695 (diff)
New experimental sample selector (enable using --with-experimental argument on ./configure).
Diffstat (limited to 'src/instrument.cc')
-rw-r--r--src/instrument.cc23
1 files changed, 22 insertions, 1 deletions
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<Sample*> 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;