Mercurial > hg > tony
diff src/MainWindow.cpp @ 158:e1a2c175a0e0
Fix up wiring for pitch gain control
author | Chris Cannam |
---|---|
date | Thu, 23 Jan 2014 09:30:38 +0000 |
parents | 752870e80dff |
children | 180e6af1806c |
line wrap: on
line diff
--- a/src/MainWindow.cpp Wed Jan 22 18:15:43 2014 -0500 +++ b/src/MainWindow.cpp Thu Jan 23 09:30:38 2014 +0000 @@ -212,24 +212,22 @@ connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); - /* not there yet... m_gainPitch = new AudioDial(frame); - m_gainPitch->setMinimum(0); - m_gainPitch->setMaximum(200); - m_gainPitch->setValue(100); + m_gainPitch->setMinimum(-50); + m_gainPitch->setMaximum(50); + m_gainPitch->setValue(0); + m_gainPitch->setDefaultValue(0); m_gainPitch->setFixedWidth(24); m_gainPitch->setFixedHeight(24); m_gainPitch->setNotchesVisible(true); m_gainPitch->setPageStep(10); - m_gainPitch->setObjectName(tr("Playback Speedup")); - m_gainPitch->setDefaultValue(100); - m_gainPitch->setRangeMapper(new PlaySpeedRangeMapper(0, 200)); + m_gainPitch->setObjectName(tr("Pitch Track Gain")); + m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB"))); m_gainPitch->setShowToolTip(true); connect(m_gainPitch, SIGNAL(valueChanged(int)), - this, SLOT(playSpeedChanged(int))); + this, SLOT(pitchGainChanged(int))); connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); - */ layout->setSpacing(4); layout->addWidget(m_overview, 0, 1); @@ -807,7 +805,7 @@ connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); - //toolbar->addWidget(m_gainPitch); + toolbar->addWidget(m_gainPitch); // Notes QLabel *icon_notes = new QLabel; @@ -1664,31 +1662,17 @@ m_playSpeed->setValue(m_playSpeed->defaultValue()); } -/* Pitch Gain Functions void MainWindow::pitchGainChanged(int position) { - PlaySpeedRangeMapper mapper(0, 200); + float level = m_gainPitch->mappedValue(); + float gain = powf(10, level / 20.0); - float percent = m_gainPitch->mappedValue(); - float factor = mapper.getFactorForValue(percent); + cerr << "gain = " << gain << " (" << position << " dB)" << endl; - cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl; + contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position)); - bool something = (position != 100); - - int pc = lrintf(percent); - - if (!something) { - contextHelpChanged(tr("Pitch Gain: Normal")); - } else { - contextHelpChanged(tr("Pitch Gain: %1%2%") - .arg(position > 100 ? "+" : "") - .arg(pc)); - } - - //m_playSource->setTimeStretch(factor); - // TODO: pitch gain + m_analyser->setGain(Analyser::PitchTrack, gain); updateMenuStates(); } @@ -1716,7 +1700,6 @@ { m_gainPitch->setValue(m_gainPitch->defaultValue()); } -*/ void MainWindow::updateVisibleRangeDisplay(Pane *p) const