From 11b8e6db937f4c77942febb69f7b41e87ae0b6e0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 Apr 2014 12:26:56 +0200 Subject: Fix brain-o in zero crossing search algorithm. --- dgedit/canvastoolselections.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'dgedit') 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. -- cgit v1.2.3