diff main/MainWindow.cpp @ 12:ee967635c728

* Some work on making the time stretcher squash as well as stretch
author Chris Cannam
date Tue, 12 Sep 2006 16:43:00 +0000
parents 0dbd08e365ce
children 085f34c73939
line wrap: on
line diff
--- a/main/MainWindow.cpp	Tue Sep 12 12:15:44 2006 +0000
+++ b/main/MainWindow.cpp	Tue Sep 12 16:43:00 2006 +0000
@@ -153,8 +153,8 @@
     m_fader = new Fader(frame, false);
 
     m_playSpeed = new AudioDial(frame);
-    m_playSpeed->setMinimum(1);
-    m_playSpeed->setMaximum(10);
+    m_playSpeed->setMinimum(0);
+    m_playSpeed->setMaximum(20);
     m_playSpeed->setValue(10);
     m_playSpeed->setFixedWidth(24);
     m_playSpeed->setFixedHeight(24);
@@ -2853,9 +2853,21 @@
 void
 MainWindow::playSpeedChanged(int speed)
 {
-    int factor = 11 - speed;
+    static float factors[] = {
+        1.0, 1.1, 1.2, 1.3, 1.5, 1.7, 2.0, 3.0, 4.0, 6.0, 10.0
+    };
+    float factor = factors[speed >= 10 ? speed - 10 : 10 - speed];
+//    int factor = 11 - speed;
+    if (speed > 10) factor = 1.0 / factor;
+    std::cerr << "factor = " << factor << std::endl;
+
+    int iinc = 128;
+    int oinc = lrintf(iinc * factor);
+    factor = (float(oinc) + 0.01) / iinc;
+    std::cerr << "corrected factor = " << factor << std::endl;
+
     m_playSpeed->setToolTip(tr("Playback speed: %1")
-			    .arg(factor > 1 ?
+			    .arg(factor != 1 ?
 				 QString("1/%1").arg(factor) :
 				 tr("Full")));
     m_playSource->setSlowdownFactor(factor);