Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 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 | 9ae8a300cf7f |
children | 28ccb621d1af 0f46daf55706 |
comparison
equal
deleted
inserted
replaced
1029:14e312cf8e95 | 1031:2d524c9eee33 |
---|---|
234 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 234 connect(m_fader, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
235 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 235 connect(m_fader, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
236 | 236 |
237 m_playSpeed = new AudioDial(frame); | 237 m_playSpeed = new AudioDial(frame); |
238 m_playSpeed->setMinimum(0); | 238 m_playSpeed->setMinimum(0); |
239 m_playSpeed->setMaximum(200); | 239 m_playSpeed->setMaximum(120); |
240 m_playSpeed->setValue(100); | 240 m_playSpeed->setValue(60); |
241 m_playSpeed->setFixedWidth(32); | 241 m_playSpeed->setFixedWidth(32); |
242 m_playSpeed->setFixedHeight(32); | 242 m_playSpeed->setFixedHeight(32); |
243 m_playSpeed->setNotchesVisible(true); | 243 m_playSpeed->setNotchesVisible(true); |
244 m_playSpeed->setPageStep(10); | 244 m_playSpeed->setPageStep(10); |
245 m_playSpeed->setObjectName(tr("Playback Speedup")); | 245 m_playSpeed->setObjectName(tr("Playback Speed")); |
246 m_playSpeed->setDefaultValue(100); | 246 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper); |
247 m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200)); | 247 m_playSpeed->setDefaultValue(60); |
248 m_playSpeed->setShowToolTip(true); | 248 m_playSpeed->setShowToolTip(true); |
249 connect(m_playSpeed, SIGNAL(valueChanged(int)), | 249 connect(m_playSpeed, SIGNAL(valueChanged(int)), |
250 this, SLOT(playSpeedChanged(int))); | 250 this, SLOT(playSpeedChanged(int))); |
251 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 251 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
252 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 252 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
3872 } | 3872 } |
3873 | 3873 |
3874 void | 3874 void |
3875 MainWindow::playSpeedChanged(int position) | 3875 MainWindow::playSpeedChanged(int position) |
3876 { | 3876 { |
3877 PlaySpeedRangeMapper mapper(0, 200); | 3877 PlaySpeedRangeMapper mapper; |
3878 | 3878 |
3879 double percent = m_playSpeed->mappedValue(); | 3879 double percent = m_playSpeed->mappedValue(); |
3880 double factor = mapper.getFactorForValue(percent); | 3880 double factor = mapper.getFactorForValue(percent); |
3881 | 3881 |
3882 // cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl; | 3882 // cerr << "play speed position = " << position << " (range 0-120) percent = " << percent << " factor = " << factor << endl; |
3883 | 3883 |
3884 bool something = (position != 100); | 3884 int centre = m_playSpeed->defaultValue(); |
3885 | 3885 |
3886 int pc = int(lrint(percent)); | 3886 // Percentage is shown to 0dp if >100, to 1dp if <100; factor is |
3887 | 3887 // shown to 3sf |
3888 if (!something) { | 3888 |
3889 char pcbuf[30]; | |
3890 char facbuf[30]; | |
3891 | |
3892 if (position == centre) { | |
3889 contextHelpChanged(tr("Playback speed: Normal")); | 3893 contextHelpChanged(tr("Playback speed: Normal")); |
3894 } else if (position < centre) { | |
3895 sprintf(pcbuf, "%.1f", percent); | |
3896 sprintf(facbuf, "%.3g", 1.0 / factor); | |
3897 contextHelpChanged(tr("Playback speed: %1% (%2x slower)") | |
3898 .arg(pcbuf) | |
3899 .arg(facbuf)); | |
3890 } else { | 3900 } else { |
3891 contextHelpChanged(tr("Playback speed: %1%2%") | 3901 sprintf(pcbuf, "%.0f", percent); |
3892 .arg(position > 100 ? "+" : "") | 3902 sprintf(facbuf, "%.3g", factor); |
3893 .arg(pc)); | 3903 contextHelpChanged(tr("Playback speed: %1% (%2x faster)") |
3894 } | 3904 .arg(pcbuf) |
3895 | 3905 .arg(facbuf)); |
3896 m_playSource->setTimeStretch(factor); | 3906 } |
3907 | |
3908 m_playSource->setTimeStretch(1.0 / factor); // factor is a speedup | |
3897 | 3909 |
3898 updateMenuStates(); | 3910 updateMenuStates(); |
3899 } | 3911 } |
3900 | 3912 |
3901 void | 3913 void |