summaryrefslogtreecommitdiff
path: root/src/powerlist.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 16:52:21 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-14 16:52:21 +0200
commitb79a14e33ade7285d7309ef544d89c60f3d5b3ec (patch)
treeb1d092337f54b699dd139e2af9c315610daf12bc /src/powerlist.cc
parentb69389f609c8c9c441d0251510f6b578a9437f6a (diff)
Make lower limit to 'width' (ie. stddev) of normal distribution function.
Diffstat (limited to 'src/powerlist.cc')
-rw-r--r--src/powerlist.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/powerlist.cc b/src/powerlist.cc
index 1888733..96f2c9b 100644
--- a/src/powerlist.cc
+++ b/src/powerlist.cc
@@ -32,6 +32,14 @@
#include <hugin.hpp>
+/**
+ * Minimum sample set size.
+ * Smaller means wider 'velocity groups'.
+ * Limited by sample set size, ie. only kicks in if sample set size is smaller
+ * than this number.
+ */
+#define MIN_SAMPLE_SET_SIZE 10
+
// Enable to calculate power on old samples without power attribute
//#define AUTO_CALCULATE_POWER
@@ -213,8 +221,12 @@ Sample *PowerList::get(level_t level)
float power_span = power_max - power_min;
+ // Width is limited to at least 10. Fioxes problem with instrument with a
+ // sample set smaller than MIN_SAMPLE_SET_SIZE.
+ float width = fmax(samples.size(), MIN_SAMPLE_SET_SIZE);
+
// Spread out at most 1.5 samples away from center
- float stddev = power_span / samples.size() * 1.5;
+ float stddev = power_span / width * 1.5;
// Cut off mean value with stddev/2 in both ends in order to make room for
// downwards expansion on velocity 0 and upwards expansion on velocity 1.