summaryrefslogtreecommitdiff
path: root/dgedit/canvastoolselections.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-04-20 21:01:02 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-04-20 21:01:02 +0200
commit60fd5c525b59e429c9b0a4c3d500b66f26ef7c85 (patch)
treeb24eb6a562d5a8ab8aadff60cbabf3ade6cc3307 /dgedit/canvastoolselections.cc
parent35c4f0b6ca508f428c31ab991633142b1384e382 (diff)
Rework sliders in 'generate' tab. Add 'hold' slider.
Diffstat (limited to 'dgedit/canvastoolselections.cc')
-rw-r--r--dgedit/canvastoolselections.cc18
1 files changed, 12 insertions, 6 deletions
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 ||