diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-04-18 12:26:56 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2014-04-18 12:26:56 +0200 |
commit | 11b8e6db937f4c77942febb69f7b41e87ae0b6e0 (patch) | |
tree | de4913a8760d8af2e36922d1aff1e9ff6840ca61 /dgedit/canvastoolselections.cc | |
parent | d296ad38cb4f0fdd932fdf154b258e8c837d51dd (diff) |
Fix brain-o in zero crossing search algorithm.
Diffstat (limited to 'dgedit/canvastoolselections.cc')
-rw-r--r-- | dgedit/canvastoolselections.cc | 11 |
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. |