summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-30 13:43:51 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-30 13:43:51 +0200
commitfcd0aec1f98ba4d77630a4b8ed1037a2efb390d0 (patch)
tree08d37fabe5222f929700e74c969f72ba3131a6c8
parent6fa22c8eab8cbae74079a344a759fbd179ed857e (diff)
Retry sample::get if the same sample is about to be played twice in a row. At most /n/ times.
-rw-r--r--src/powerlist.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/powerlist.cc b/src/powerlist.cc
index e0809ab..236bcf8 100644
--- a/src/powerlist.cc
+++ b/src/powerlist.cc
@@ -52,6 +52,7 @@ static float box_muller_transform(float mean, float stddev)
PowerList::PowerList()
{
power_max = 0;
+ lastsample = NULL;
}
#define THRES 1.0
@@ -202,7 +203,7 @@ void PowerList::finalise()
Sample *PowerList::get(level_t level)
{
-
+ int retry = 3; // TODO: This must be user controllable via the UI.
Sample *sample = NULL;
float power = 0;
@@ -210,6 +211,7 @@ Sample *PowerList::get(level_t level)
float mean = level * power_max;
float stddev = power_max / samples.size() * 1.5;
+again:
float lvl = box_muller_transform(mean, stddev);
DEBUG(rand, "level: %f, lvl: %f (mean: %.2f, stddev: %.2f)\n",
@@ -232,5 +234,9 @@ Sample *PowerList::get(level_t level)
DEBUG(rand, "Found power %f\n", power);
+ if(lastsample == sample && retry--) goto again;
+
+ lastsample = sample;
+
return sample;
}