From fcd0aec1f98ba4d77630a4b8ed1037a2efb390d0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Wed, 30 Apr 2014 13:43:51 +0200 Subject: Retry sample::get if the same sample is about to be played twice in a row. At most /n/ times. --- src/powerlist.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3