comparison 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
comparison
equal deleted inserted replaced
157:752870e80dff 158:e1a2c175a0e0
210 connect(m_playSpeed, SIGNAL(valueChanged(int)), 210 connect(m_playSpeed, SIGNAL(valueChanged(int)),
211 this, SLOT(playSpeedChanged(int))); 211 this, SLOT(playSpeedChanged(int)));
212 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); 212 connect(m_playSpeed, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
213 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); 213 connect(m_playSpeed, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
214 214
215 /* not there yet...
216 m_gainPitch = new AudioDial(frame); 215 m_gainPitch = new AudioDial(frame);
217 m_gainPitch->setMinimum(0); 216 m_gainPitch->setMinimum(-50);
218 m_gainPitch->setMaximum(200); 217 m_gainPitch->setMaximum(50);
219 m_gainPitch->setValue(100); 218 m_gainPitch->setValue(0);
219 m_gainPitch->setDefaultValue(0);
220 m_gainPitch->setFixedWidth(24); 220 m_gainPitch->setFixedWidth(24);
221 m_gainPitch->setFixedHeight(24); 221 m_gainPitch->setFixedHeight(24);
222 m_gainPitch->setNotchesVisible(true); 222 m_gainPitch->setNotchesVisible(true);
223 m_gainPitch->setPageStep(10); 223 m_gainPitch->setPageStep(10);
224 m_gainPitch->setObjectName(tr("Playback Speedup")); 224 m_gainPitch->setObjectName(tr("Pitch Track Gain"));
225 m_gainPitch->setDefaultValue(100); 225 m_gainPitch->setRangeMapper(new LinearRangeMapper(-50, 50, -25, 25, tr("dB")));
226 m_gainPitch->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
227 m_gainPitch->setShowToolTip(true); 226 m_gainPitch->setShowToolTip(true);
228 connect(m_gainPitch, SIGNAL(valueChanged(int)), 227 connect(m_gainPitch, SIGNAL(valueChanged(int)),
229 this, SLOT(playSpeedChanged(int))); 228 this, SLOT(pitchGainChanged(int)));
230 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); 229 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
231 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); 230 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
232 */
233 231
234 layout->setSpacing(4); 232 layout->setSpacing(4);
235 layout->addWidget(m_overview, 0, 1); 233 layout->addWidget(m_overview, 0, 1);
236 layout->addWidget(scroll, 1, 1); 234 layout->addWidget(scroll, 1, 1);
237 235
805 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track")); 803 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
806 m_playPitch->setCheckable(true); 804 m_playPitch->setCheckable(true);
807 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); 805 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
808 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); 806 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
809 807
810 //toolbar->addWidget(m_gainPitch); 808 toolbar->addWidget(m_gainPitch);
811 809
812 // Notes 810 // Notes
813 QLabel *icon_notes = new QLabel; 811 QLabel *icon_notes = new QLabel;
814 icon_notes->setFixedWidth(40); 812 icon_notes->setFixedWidth(40);
815 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 813 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1662 MainWindow::restoreNormalPlayback() 1660 MainWindow::restoreNormalPlayback()
1663 { 1661 {
1664 m_playSpeed->setValue(m_playSpeed->defaultValue()); 1662 m_playSpeed->setValue(m_playSpeed->defaultValue());
1665 } 1663 }
1666 1664
1667 /* Pitch Gain Functions
1668 void 1665 void
1669 MainWindow::pitchGainChanged(int position) 1666 MainWindow::pitchGainChanged(int position)
1670 { 1667 {
1671 PlaySpeedRangeMapper mapper(0, 200); 1668 float level = m_gainPitch->mappedValue();
1672 1669 float gain = powf(10, level / 20.0);
1673 float percent = m_gainPitch->mappedValue(); 1670
1674 float factor = mapper.getFactorForValue(percent); 1671 cerr << "gain = " << gain << " (" << position << " dB)" << endl;
1675 1672
1676 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl; 1673 contextHelpChanged(tr("Pitch Gain: %1 dB").arg(position));
1677 1674
1678 bool something = (position != 100); 1675 m_analyser->setGain(Analyser::PitchTrack, gain);
1679
1680 int pc = lrintf(percent);
1681
1682 if (!something) {
1683 contextHelpChanged(tr("Pitch Gain: Normal"));
1684 } else {
1685 contextHelpChanged(tr("Pitch Gain: %1%2%")
1686 .arg(position > 100 ? "+" : "")
1687 .arg(pc));
1688 }
1689
1690 //m_playSource->setTimeStretch(factor);
1691 // TODO: pitch gain
1692 1676
1693 updateMenuStates(); 1677 updateMenuStates();
1694 } 1678 }
1695 1679
1696 void 1680 void
1714 void 1698 void
1715 MainWindow::restoreNormalPitchGain() 1699 MainWindow::restoreNormalPitchGain()
1716 { 1700 {
1717 m_gainPitch->setValue(m_gainPitch->defaultValue()); 1701 m_gainPitch->setValue(m_gainPitch->defaultValue());
1718 } 1702 }
1719 */
1720 1703
1721 void 1704 void
1722 MainWindow::updateVisibleRangeDisplay(Pane *p) const 1705 MainWindow::updateVisibleRangeDisplay(Pane *p) const
1723 { 1706 {
1724 if (!getMainModel() || !p) { 1707 if (!getMainModel() || !p) {