comparison src/MainWindow.cpp @ 157:752870e80dff

started adding wiring for Pitch gain control, all commented out
author Justin Salamon <justin.salamon@nyu.edu>
date Wed, 22 Jan 2014 18:15:43 -0500
parents 8571ad52349a
children e1a2c175a0e0
comparison
equal deleted inserted replaced
156:8571ad52349a 157:752870e80dff
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);
217 m_gainPitch->setMinimum(0);
218 m_gainPitch->setMaximum(200);
219 m_gainPitch->setValue(100);
220 m_gainPitch->setFixedWidth(24);
221 m_gainPitch->setFixedHeight(24);
222 m_gainPitch->setNotchesVisible(true);
223 m_gainPitch->setPageStep(10);
224 m_gainPitch->setObjectName(tr("Playback Speedup"));
225 m_gainPitch->setDefaultValue(100);
226 m_gainPitch->setRangeMapper(new PlaySpeedRangeMapper(0, 200));
227 m_gainPitch->setShowToolTip(true);
228 connect(m_gainPitch, SIGNAL(valueChanged(int)),
229 this, SLOT(playSpeedChanged(int)));
230 connect(m_gainPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
231 connect(m_gainPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
232 */
233
215 layout->setSpacing(4); 234 layout->setSpacing(4);
216 layout->addWidget(m_overview, 0, 1); 235 layout->addWidget(m_overview, 0, 1);
217 layout->addWidget(scroll, 1, 1); 236 layout->addWidget(scroll, 1, 1);
218 237
219 layout->setColumnStretch(1, 10); 238 layout->setColumnStretch(1, 10);
786 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track")); 805 m_playPitch = toolbar->addAction(il.load("speaker"), tr("Play Pitch Track"));
787 m_playPitch->setCheckable(true); 806 m_playPitch->setCheckable(true);
788 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); 807 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled()));
789 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); 808 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool)));
790 809
791 //toolbar->addWidget(m_volumePitch); 810 //toolbar->addWidget(m_gainPitch);
792 811
793 // Notes 812 // Notes
794 QLabel *icon_notes = new QLabel; 813 QLabel *icon_notes = new QLabel;
795 icon_notes->setFixedWidth(40); 814 icon_notes->setFixedWidth(40);
796 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 815 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1604 settings.beginGroup("MainWindow"); 1623 settings.beginGroup("MainWindow");
1605 settings.setValue("playsharpen", m_playSharpen->isChecked()); 1624 settings.setValue("playsharpen", m_playSharpen->isChecked());
1606 settings.endGroup(); 1625 settings.endGroup();
1607 1626
1608 playSpeedChanged(m_playSpeed->value()); 1627 playSpeedChanged(m_playSpeed->value());
1628 // TODO: pitch gain?
1609 } 1629 }
1610 1630
1611 void 1631 void
1612 MainWindow::playMonoToggled() 1632 MainWindow::playMonoToggled()
1613 { 1633 {
1615 settings.beginGroup("MainWindow"); 1635 settings.beginGroup("MainWindow");
1616 settings.setValue("playmono", m_playMono->isChecked()); 1636 settings.setValue("playmono", m_playMono->isChecked());
1617 settings.endGroup(); 1637 settings.endGroup();
1618 1638
1619 playSpeedChanged(m_playSpeed->value()); 1639 playSpeedChanged(m_playSpeed->value());
1640 // TODO: pitch gain?
1620 } 1641 }
1621 1642
1622 void 1643 void
1623 MainWindow::speedUpPlayback() 1644 MainWindow::speedUpPlayback()
1624 { 1645 {
1640 void 1661 void
1641 MainWindow::restoreNormalPlayback() 1662 MainWindow::restoreNormalPlayback()
1642 { 1663 {
1643 m_playSpeed->setValue(m_playSpeed->defaultValue()); 1664 m_playSpeed->setValue(m_playSpeed->defaultValue());
1644 } 1665 }
1666
1667 /* Pitch Gain Functions
1668 void
1669 MainWindow::pitchGainChanged(int position)
1670 {
1671 PlaySpeedRangeMapper mapper(0, 200);
1672
1673 float percent = m_gainPitch->mappedValue();
1674 float factor = mapper.getFactorForValue(percent);
1675
1676 cerr << "speed = " << position << " percent = " << percent << " factor = " << factor << endl;
1677
1678 bool something = (position != 100);
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
1693 updateMenuStates();
1694 }
1695
1696 void
1697 MainWindow::increasePitchGain()
1698 {
1699 int value = m_gainPitch->value();
1700 value = value + m_gainPitch->pageStep();
1701 if (value > m_gainPitch->maximum()) value = m_gainPitch->maximum();
1702 m_gainPitch->setValue(value);
1703 }
1704
1705 void
1706 MainWindow::decreasePitchGain()
1707 {
1708 int value = m_gainPitch->value();
1709 value = value - m_gainPitch->pageStep();
1710 if (value < m_gainPitch->minimum()) value = m_gainPitch->minimum();
1711 m_gainPitch->setValue(value);
1712 }
1713
1714 void
1715 MainWindow::restoreNormalPitchGain()
1716 {
1717 m_gainPitch->setValue(m_gainPitch->defaultValue());
1718 }
1719 */
1645 1720
1646 void 1721 void
1647 MainWindow::updateVisibleRangeDisplay(Pane *p) const 1722 MainWindow::updateVisibleRangeDisplay(Pane *p) const
1648 { 1723 {
1649 if (!getMainModel() || !p) { 1724 if (!getMainModel() || !p) {