Mercurial > hg > tony
comparison src/MainWindow.cpp @ 160:106fdf38c6c9
added pan knobs for Audio, Pitch and Notes
author | Justin Salamon <justin.salamon@nyu.edu> |
---|---|
date | Thu, 23 Jan 2014 17:18:53 -0500 |
parents | 180e6af1806c |
children | 62ceae757fe0 |
comparison
equal
deleted
inserted
replaced
159:180e6af1806c | 160:106fdf38c6c9 |
---|---|
262 connect(m_gainNotes, SIGNAL(valueChanged(int)), | 262 connect(m_gainNotes, SIGNAL(valueChanged(int)), |
263 this, SLOT(notesGainChanged(int))); | 263 this, SLOT(notesGainChanged(int))); |
264 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | 264 connect(m_gainNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); |
265 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | 265 connect(m_gainNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); |
266 // End of Gain controls | 266 // End of Gain controls |
267 | |
268 // Pan controls | |
269 m_panAudio = new AudioDial(frame); | |
270 m_panAudio->setMinimum(-100); | |
271 m_panAudio->setMaximum(100); | |
272 m_panAudio->setValue(-100); | |
273 m_panAudio->setDefaultValue(-100); | |
274 m_panAudio->setFixedWidth(24); | |
275 m_panAudio->setFixedHeight(24); | |
276 m_panAudio->setNotchesVisible(true); | |
277 m_panAudio->setPageStep(10); | |
278 m_panAudio->setObjectName(tr("Audio Track Pan")); | |
279 m_panAudio->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); | |
280 m_panAudio->setShowToolTip(true); | |
281 connect(m_panAudio, SIGNAL(valueChanged(int)), | |
282 this, SLOT(audioPanChanged(int))); | |
283 connect(m_panAudio, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | |
284 connect(m_panAudio, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | |
285 | |
286 m_panPitch = new AudioDial(frame); | |
287 m_panPitch->setMinimum(-100); | |
288 m_panPitch->setMaximum(100); | |
289 m_panPitch->setValue(100); | |
290 m_panPitch->setDefaultValue(100); | |
291 m_panPitch->setFixedWidth(24); | |
292 m_panPitch->setFixedHeight(24); | |
293 m_panPitch->setNotchesVisible(true); | |
294 m_panPitch->setPageStep(10); | |
295 m_panPitch->setObjectName(tr("Pitch Track Pan")); | |
296 m_panPitch->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); | |
297 m_panPitch->setShowToolTip(true); | |
298 connect(m_panPitch, SIGNAL(valueChanged(int)), | |
299 this, SLOT(pitchPanChanged(int))); | |
300 connect(m_panPitch, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | |
301 connect(m_panPitch, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | |
302 | |
303 m_panNotes = new AudioDial(frame); | |
304 m_panNotes->setMinimum(-100); | |
305 m_panNotes->setMaximum(100); | |
306 m_panNotes->setValue(100); | |
307 m_panNotes->setDefaultValue(100); | |
308 m_panNotes->setFixedWidth(24); | |
309 m_panNotes->setFixedHeight(24); | |
310 m_panNotes->setNotchesVisible(true); | |
311 m_panNotes->setPageStep(10); | |
312 m_panNotes->setObjectName(tr("Notes Track Pan")); | |
313 m_panNotes->setRangeMapper(new LinearRangeMapper(-100, 100, -100, 100, tr(""))); | |
314 m_panNotes->setShowToolTip(true); | |
315 connect(m_panNotes, SIGNAL(valueChanged(int)), | |
316 this, SLOT(notesPanChanged(int))); | |
317 connect(m_panNotes, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); | |
318 connect(m_panNotes, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); | |
319 // End of Pan controls | |
267 | 320 |
268 layout->setSpacing(4); | 321 layout->setSpacing(4); |
269 layout->addWidget(m_overview, 0, 1); | 322 layout->addWidget(m_overview, 0, 1); |
270 layout->addWidget(scroll, 1, 1); | 323 layout->addWidget(scroll, 1, 1); |
271 | 324 |
823 m_playAudio->setCheckable(true); | 876 m_playAudio->setCheckable(true); |
824 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled())); | 877 connect(m_playAudio, SIGNAL(triggered()), this, SLOT(playAudioToggled())); |
825 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool))); | 878 connect(this, SIGNAL(canPlay(bool)), m_playAudio, SLOT(setEnabled(bool))); |
826 | 879 |
827 toolbar->addWidget(m_gainAudio); | 880 toolbar->addWidget(m_gainAudio); |
881 toolbar->addWidget(m_panAudio); | |
828 | 882 |
829 // Pitch (f0) | 883 // Pitch (f0) |
830 QLabel *icon_pitch = new QLabel; | 884 QLabel *icon_pitch = new QLabel; |
831 icon_pitch->setFixedWidth(40); | 885 icon_pitch->setFixedWidth(40); |
832 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter); | 886 icon_pitch->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
842 m_playPitch->setCheckable(true); | 896 m_playPitch->setCheckable(true); |
843 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); | 897 connect(m_playPitch, SIGNAL(triggered()), this, SLOT(playPitchToggled())); |
844 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); | 898 connect(this, SIGNAL(canPlay(bool)), m_playPitch, SLOT(setEnabled(bool))); |
845 | 899 |
846 toolbar->addWidget(m_gainPitch); | 900 toolbar->addWidget(m_gainPitch); |
901 toolbar->addWidget(m_panPitch); | |
847 | 902 |
848 // Notes | 903 // Notes |
849 QLabel *icon_notes = new QLabel; | 904 QLabel *icon_notes = new QLabel; |
850 icon_notes->setFixedWidth(40); | 905 icon_notes->setFixedWidth(40); |
851 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter); | 906 icon_notes->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
861 m_playNotes->setCheckable(true); | 916 m_playNotes->setCheckable(true); |
862 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled())); | 917 connect(m_playNotes, SIGNAL(triggered()), this, SLOT(playNotesToggled())); |
863 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool))); | 918 connect(this, SIGNAL(canPlay(bool)), m_playNotes, SLOT(setEnabled(bool))); |
864 | 919 |
865 toolbar->addWidget(m_gainNotes); | 920 toolbar->addWidget(m_gainNotes); |
921 toolbar->addWidget(m_panNotes); | |
866 | 922 |
867 // Spectrogram | 923 // Spectrogram |
868 QLabel *icon_spectrogram = new QLabel; | 924 QLabel *icon_spectrogram = new QLabel; |
869 icon_spectrogram->setFixedWidth(40); | 925 icon_spectrogram->setFixedWidth(40); |
870 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter); | 926 icon_spectrogram->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
1818 { | 1874 { |
1819 m_gainNotes->setValue(m_gainNotes->defaultValue()); | 1875 m_gainNotes->setValue(m_gainNotes->defaultValue()); |
1820 } | 1876 } |
1821 | 1877 |
1822 void | 1878 void |
1879 MainWindow::audioPanChanged(int position) | |
1880 { | |
1881 float level = m_panAudio->mappedValue(); | |
1882 float pan = level/100.f; | |
1883 | |
1884 cerr << "pan = " << pan << " (" << position << ")" << endl; | |
1885 | |
1886 contextHelpChanged(tr("Audio Pan: %1").arg(position)); | |
1887 | |
1888 m_analyser->setPan(Analyser::Audio, pan); | |
1889 | |
1890 updateMenuStates(); | |
1891 } | |
1892 | |
1893 void | |
1894 MainWindow::increaseAudioPan() | |
1895 { | |
1896 int value = m_panAudio->value(); | |
1897 value = value + m_panAudio->pageStep(); | |
1898 if (value > m_panAudio->maximum()) value = m_panAudio->maximum(); | |
1899 m_panAudio->setValue(value); | |
1900 } | |
1901 | |
1902 void | |
1903 MainWindow::decreaseAudioPan() | |
1904 { | |
1905 int value = m_panAudio->value(); | |
1906 value = value - m_panAudio->pageStep(); | |
1907 if (value < m_panAudio->minimum()) value = m_panAudio->minimum(); | |
1908 m_panAudio->setValue(value); | |
1909 } | |
1910 | |
1911 void | |
1912 MainWindow::restoreNormalAudioPan() | |
1913 { | |
1914 m_panAudio->setValue(m_panAudio->defaultValue()); | |
1915 } | |
1916 | |
1917 void | |
1918 MainWindow::pitchPanChanged(int position) | |
1919 { | |
1920 float level = m_panPitch->mappedValue(); | |
1921 float pan = level/100.f; | |
1922 | |
1923 cerr << "pan = " << pan << " (" << position << ")" << endl; | |
1924 | |
1925 contextHelpChanged(tr("Pitch Pan: %1").arg(position)); | |
1926 | |
1927 m_analyser->setPan(Analyser::PitchTrack, pan); | |
1928 | |
1929 updateMenuStates(); | |
1930 } | |
1931 | |
1932 void | |
1933 MainWindow::increasePitchPan() | |
1934 { | |
1935 int value = m_panPitch->value(); | |
1936 value = value + m_panPitch->pageStep(); | |
1937 if (value > m_panPitch->maximum()) value = m_panPitch->maximum(); | |
1938 m_panPitch->setValue(value); | |
1939 } | |
1940 | |
1941 void | |
1942 MainWindow::decreasePitchPan() | |
1943 { | |
1944 int value = m_panPitch->value(); | |
1945 value = value - m_panPitch->pageStep(); | |
1946 if (value < m_panPitch->minimum()) value = m_panPitch->minimum(); | |
1947 m_panPitch->setValue(value); | |
1948 } | |
1949 | |
1950 void | |
1951 MainWindow::restoreNormalPitchPan() | |
1952 { | |
1953 m_panPitch->setValue(m_panPitch->defaultValue()); | |
1954 } | |
1955 | |
1956 void | |
1957 MainWindow::notesPanChanged(int position) | |
1958 { | |
1959 float level = m_panNotes->mappedValue(); | |
1960 float pan = level/100.f; | |
1961 | |
1962 cerr << "pan = " << pan << " (" << position << ")" << endl; | |
1963 | |
1964 contextHelpChanged(tr("Notes Pan: %1").arg(position)); | |
1965 | |
1966 m_analyser->setPan(Analyser::Notes, pan); | |
1967 | |
1968 updateMenuStates(); | |
1969 } | |
1970 | |
1971 void | |
1972 MainWindow::increaseNotesPan() | |
1973 { | |
1974 int value = m_panNotes->value(); | |
1975 value = value + m_panNotes->pageStep(); | |
1976 if (value > m_panNotes->maximum()) value = m_panNotes->maximum(); | |
1977 m_panNotes->setValue(value); | |
1978 } | |
1979 | |
1980 void | |
1981 MainWindow::decreaseNotesPan() | |
1982 { | |
1983 int value = m_panNotes->value(); | |
1984 value = value - m_panNotes->pageStep(); | |
1985 if (value < m_panNotes->minimum()) value = m_panNotes->minimum(); | |
1986 m_panNotes->setValue(value); | |
1987 } | |
1988 | |
1989 void | |
1990 MainWindow::restoreNormalNotesPan() | |
1991 { | |
1992 m_panNotes->setValue(m_panNotes->defaultValue()); | |
1993 } | |
1994 | |
1995 void | |
1823 MainWindow::updateVisibleRangeDisplay(Pane *p) const | 1996 MainWindow::updateVisibleRangeDisplay(Pane *p) const |
1824 { | 1997 { |
1825 if (!getMainModel() || !p) { | 1998 if (!getMainModel() || !p) { |
1826 return; | 1999 return; |
1827 } | 2000 } |