Mercurial > hg > sonic-visualiser
changeset 1031:2d524c9eee33
Make the play-speed dial settings much easier to understand and use (fixes #1328)
author | Chris Cannam |
---|---|
date | Mon, 13 Jul 2015 14:39:41 +0100 |
parents | 14e312cf8e95 |
children | 28ccb621d1af 0f46daf55706 558302a9335c |
files | .hgsubstate main/MainWindow.cpp |
diffstat | 2 files changed, 30 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Tue Jul 07 17:28:58 2015 +0100 +++ b/.hgsubstate Mon Jul 13 14:39:41 2015 +0100 @@ -1,5 +1,5 @@ d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay 55ece8862b6d3a54aad271a53f9c1615e5d3bcf8 sv-dependency-builds -ad998a2fe9e286113edd3e2f2cfa70b835b3f7e9 svapp +45054b36ddbfe1d93afcef2eb122579e4bdc4e06 svapp ed207f89aaefc110e8b3debb07c86299cb6b05ae svcore e5d40d89b1ec879dfe9e64b0fc440c69d1adf6e2 svgui
--- a/main/MainWindow.cpp Tue Jul 07 17:28:58 2015 +0100 +++ b/main/MainWindow.cpp Mon Jul 13 14:39:41 2015 +0100 @@ -236,15 +236,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))); @@ -3874,26 +3874,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(); }