Mercurial > hg > sonic-visualiser
changeset 60:06b3c3f437e6
* Make audio dial remember its more accurate mapped value as well as its
display position
* Add tool tip support to audio dial to show values
author | Chris Cannam |
---|---|
date | Tue, 17 Oct 2006 13:04:49 +0000 (2006-10-17) |
parents | 1016a8ceceda |
children | 963e3187d920 |
files | audioio/PlaySpeedRangeMapper.cpp audioio/PlaySpeedRangeMapper.h main/MainWindow.cpp |
diffstat | 3 files changed, 34 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/PlaySpeedRangeMapper.cpp Tue Oct 17 11:42:14 2006 +0000 +++ b/audioio/PlaySpeedRangeMapper.cpp Tue Oct 17 13:04:49 2006 +0000 @@ -28,9 +28,14 @@ PlaySpeedRangeMapper::getPositionForValue(float value) const { // value is percent + float factor = getFactorForValue(value); + int position = getPositionForFactor(factor); + return position; +} - float factor = getFactorForValue(value); - +int +PlaySpeedRangeMapper::getPositionForFactor(float factor) const +{ bool slow = (factor > 1.0); if (!slow) factor = 1.0 / factor; @@ -55,6 +60,13 @@ PlaySpeedRangeMapper::getValueForPosition(int position) const { float factor = getFactorForPosition(position); + float pc = getValueForFactor(factor); + return pc; +} + +float +PlaySpeedRangeMapper::getValueForFactor(float factor) const +{ float pc; if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0; else pc = (1.0 - factor) * 100.0;
--- a/audioio/PlaySpeedRangeMapper.h Tue Oct 17 11:42:14 2006 +0000 +++ b/audioio/PlaySpeedRangeMapper.h Tue Oct 17 13:04:49 2006 +0000 @@ -26,6 +26,9 @@ virtual int getPositionForValue(float value) const; virtual float getValueForPosition(int position) const; + int getPositionForFactor(float factor) const; + float getValueForFactor(float factor) const; + float getFactorForPosition(int position) const; float getFactorForValue(float value) const;
--- a/main/MainWindow.cpp Tue Oct 17 11:42:14 2006 +0000 +++ b/main/MainWindow.cpp Tue Oct 17 13:04:49 2006 +0000 @@ -177,10 +177,11 @@ m_playSpeed->setFixedHeight(24); m_playSpeed->setNotchesVisible(true); m_playSpeed->setPageStep(10); - m_playSpeed->setToolTip(tr("Playback speed: +0%")); - m_playSpeed->setObjectName(tr("Playback Speed")); +//!!! m_playSpeed->setToolTip(tr("Playback speed: +0%")); + m_playSpeed->setObjectName(tr("Playback Speedup")); m_playSpeed->setDefaultValue(100); m_playSpeed->setRangeMapper(new PlaySpeedRangeMapper(0, 200)); + m_playSpeed->setShowToolTip(true); connect(m_playSpeed, SIGNAL(valueChanged(int)), this, SLOT(playSpeedChanged(int))); @@ -3085,20 +3086,25 @@ MainWindow::playSpeedChanged(int position) { PlaySpeedRangeMapper mapper(0, 200); - float factor = mapper.getFactorForPosition(position); - float percent = mapper.getValueForPosition(position); - -// std::cerr << "speed = " << position << " factor = " << factor << std::endl; - - bool slow = (position < 100); + + float percent = m_playSpeed->mappedValue(); + + float factor = mapper.getFactorForValue(percent); + +// float factor = mapper.getFactorForPosition(position); +// float percent = mapper.getValueForPosition(position); + + std::cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << std::endl; + +//!!! bool slow = (position < 100); bool something = (position != 100); - +/*!!! int pc = lrintf(percent); m_playSpeed->setToolTip(tr("Playback speed: %1%2%") - .arg(!slow ? "+" : "-") + .arg(!slow ? "+" : "") .arg(pc)); - +*/ m_playSharpen->setEnabled(something); m_playMono->setEnabled(something); bool sharpen = (something && m_playSharpen->isChecked());