From 60fd5c525b59e429c9b0a4c3d500b66f26ef7c85 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 20 Apr 2014 21:01:02 +0200 Subject: Rework sliders in 'generate' tab. Add 'hold' slider. --- dgedit/canvastoolselections.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'dgedit/canvastoolselections.cc') diff --git a/dgedit/canvastoolselections.cc b/dgedit/canvastoolselections.cc index 8218172..ad5e193 100644 --- a/dgedit/canvastoolselections.cc +++ b/dgedit/canvastoolselections.cc @@ -39,6 +39,7 @@ CanvasToolSelections::CanvasToolSelections(Canvas *c, Selections &s, : selections(s), selections_preview(p) { threshold = 0.5; // Default from CanvasToolThreshold + hold = 100; canvas = c; @@ -228,6 +229,11 @@ void CanvasToolSelections::thresholdChanged(double t) threshold = t; } +void CanvasToolSelections::holdChanged(int h) +{ + hold = h; +} + void CanvasToolSelections::noiseFloorChanged(int t) { double div = 666.0 / 0.00003; @@ -260,20 +266,20 @@ 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] > 0.0) { // Not crossing zero + while(data[from] > data[from-1] // Falling + && data[from-1] > 0.0 // Not crossing zero + ) { from--; } - from++; } else if(data[from] < 0.0) { - while(data[from-1] < 0.0) { // Not crossing zero + while(data[from] < data[from-1] // Rising + && data[from-1] < 0.0 // Not crossing zero + ) { from--; } - from++; } - int hold = 1000; // hold in number of samples int to = i; float runavg = fabs(data[from]); while((runavg > noise_floor || -- cgit v1.2.3