summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-25 20:04:08 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-25 20:04:08 +0200
commit64d8efa4f3abe4257120b85fb4d4a063d96edbfc (patch)
treed2cde0ad7b59c5f6acbf3c6792118ad3fda28fbf
parent541f6c214762cceb348f9657258c3db758ea667f (diff)
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.
-rw-r--r--configure.ac6
-rw-r--r--src/instrument.cc39
-rw-r--r--src/instrument.h2
-rw-r--r--src/instrumentparser.cc14
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<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(version >= VersionStr("2.0")) {
+ // Version 2.0
+ sample = powerlist.get(level * mod);
+ } else {
+ // Version 1.0
+ std::vector<Sample*> 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<Sample*>::iterator s = samplelist.begin();
- while(s != samplelist.end()) {
- powerlist.add(*s);
- s++;
+ if(version >= VersionStr("2.0")) {
+ std::vector<Sample*>::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<level_t, Sample*> 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);
+ }
}
}