summaryrefslogtreecommitdiff
path: root/dgedit
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-18 12:26:56 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-18 12:26:56 +0200
commit11b8e6db937f4c77942febb69f7b41e87ae0b6e0 (patch)
treede4913a8760d8af2e36922d1aff1e9ff6840ca61 /dgedit
parentd296ad38cb4f0fdd932fdf154b258e8c837d51dd (diff)
Fix brain-o in zero crossing search algorithm.
Diffstat (limited to 'dgedit')
-rw-r--r--dgedit/canvastoolselections.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/dgedit/canvastoolselections.cc b/dgedit/canvastoolselections.cc
index d0aa481..5967a83 100644
--- a/dgedit/canvastoolselections.cc
+++ b/dgedit/canvastoolselections.cc
@@ -260,18 +260,17 @@ void CanvasToolSelections::doAutoCreateSelections(bool preview)
if(fabs(data[i]) > fabs(threshold)) {
int from = i;
+ // FIXME: This doesn't work if the recording has a DC offset.
if(data[from] > 0.0) {
- while(data[from] > data[from-1] // Falling
- && data[from-1] > 0.0 // Not crossing zero
- ) {
+ while(data[from] > 0.0) { // Not crossing zero
from--;
}
+ from++;
} else if(data[from] < 0.0) {
- while(data[from] < data[from-1] // Rising
- && data[from-1] < 0.0 // Not crossing zero
- ) {
+ while(data[from-1] < 0.0) { // Not crossing zero
from--;
}
+ from++;
}
int minsize = 100; // attack.