diff options
author | Jonas Suhr Christensen <jsc@umbraculum.org> | 2014-05-02 13:05:52 +0200 |
---|---|---|
committer | Jonas Suhr Christensen <jsc@umbraculum.org> | 2014-05-02 13:05:52 +0200 |
commit | 7ec14ac0fa7e95dda01d396edbd190a8aeb78b2b (patch) | |
tree | f7004aedb60f20f9af0138fc26b740c1081d580c /src/powerlist.cc | |
parent | 521eaad10b2b9b7104b2b55e66864b54577e7b54 (diff) | |
parent | fcd0aec1f98ba4d77630a4b8ed1037a2efb390d0 (diff) |
Merge branch 'master' of http://git.drumgizmo.org/drumgizmo
Diffstat (limited to 'src/powerlist.cc')
-rw-r--r-- | src/powerlist.cc | 8 |
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; } |