changeset 1038:0f46daf55706 3.0-integration

Merge from default branch
author Chris Cannam
date Fri, 24 Jul 2015 16:31:54 +0100
parents afe496c595e1 (current diff) 2d524c9eee33 (diff)
children e517197049bc
files .hgsubstate main/MainWindow.cpp
diffstat 2 files changed, 30 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Tue Jul 07 17:39:06 2015 +0100
+++ b/.hgsubstate	Fri Jul 24 16:31:54 2015 +0100
@@ -1,6 +1,6 @@
 d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay
 06ed2d275a956fd1224376f74dfe170c19d3b2c2 icons/scalable
 55ece8862b6d3a54aad271a53f9c1615e5d3bcf8 sv-dependency-builds
-1b4e5a567d5819afabbf4ec79647cf6e608e019b svapp
+85e7d2418d9acf74ffe27263f6245d8ea187f5a1 svapp
 e80abd6599224bd83dd96366c26a87b1b7175bd6 svcore
 b0662a3c4679c651616f02551d6173c318136a9c svgui
--- a/main/MainWindow.cpp	Tue Jul 07 17:39:06 2015 +0100
+++ b/main/MainWindow.cpp	Fri Jul 24 16:31:54 2015 +0100
@@ -235,15 +235,15 @@
 
     m_playSpeed = new AudioDial(frame);
     m_playSpeed->setMinimum(0);
-    m_playSpeed->setMaximum(200);
-    m_playSpeed->setValue(100);
+    m_playSpeed->setMaximum(120);
+    m_playSpeed->setValue(60);
     m_playSpeed->setFixedWidth(32);
     m_playSpeed->setFixedHeight(32);
     m_playSpeed->setNotchesVisible(true);
     m_playSpeed->setPageStep(10);
-    m_playSpeed->setObjectName(tr("Playback Speedup"));
-    m_playSpeed->setDefaultValue(100);
-    m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
+    m_playSpeed->setObjectName(tr("Playback Speed"));
+    m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper);
+    m_playSpeed->setDefaultValue(60);
     m_playSpeed->setShowToolTip(true);
     connect(m_playSpeed, SIGNAL(valueChanged(int)),
 	    this, SLOT(playSpeedChanged(int)));
@@ -3869,26 +3869,38 @@
 void
 MainWindow::playSpeedChanged(int position)
 {
-    PlaySpeedRangeMapper mapper(0, 200);
+    PlaySpeedRangeMapper mapper;
 
     double percent = m_playSpeed->mappedValue();
     double factor = mapper.getFactorForValue(percent);
 
-//    cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
-
-    bool something = (position != 100);
-
-    int pc = int(lrint(percent));
-
-    if (!something) {
+//    cerr << "play speed position = " << position << " (range 0-120) percent = " << percent << " factor = " << factor << endl;
+
+    int centre = m_playSpeed->defaultValue();
+
+    // Percentage is shown to 0dp if >100, to 1dp if <100; factor is
+    // shown to 3sf
+
+    char pcbuf[30];
+    char facbuf[30];
+    
+    if (position == centre) {
         contextHelpChanged(tr("Playback speed: Normal"));
+    } else if (position < centre) {
+        sprintf(pcbuf, "%.1f", percent);
+        sprintf(facbuf, "%.3g", 1.0 / factor);
+        contextHelpChanged(tr("Playback speed: %1% (%2x slower)")
+                           .arg(pcbuf)
+                           .arg(facbuf));
     } else {
-        contextHelpChanged(tr("Playback speed: %1%2%")
-                           .arg(position > 100 ? "+" : "")
-                           .arg(pc));
+        sprintf(pcbuf, "%.0f", percent);
+        sprintf(facbuf, "%.3g", factor);
+        contextHelpChanged(tr("Playback speed: %1% (%2x faster)")
+                           .arg(pcbuf)
+                           .arg(facbuf));
     }
 
-    m_playSource->setTimeStretch(factor);
+    m_playSource->setTimeStretch(1.0 / factor); // factor is a speedup
 
     updateMenuStates();
 }