comparison main/MainWindow.cpp @ 305:f76efdd7d180

* Somewhat better MIDI-based time instant timing
author Chris Cannam
date Wed, 25 Feb 2009 11:15:22 +0000
parents fdbb3971bafc
children 8fbbfea74058
comparison
equal deleted inserted replaced
304:fdbb3971bafc 305:f76efdd7d180
117 using std::map; 117 using std::map;
118 using std::set; 118 using std::set;
119 119
120 120
121 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) : 121 MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) :
122 MainWindowBase(withAudioOutput, withOSCSupport), 122 MainWindowBase(withAudioOutput, withOSCSupport, true),
123 m_overview(0), 123 m_overview(0),
124 m_mainMenusCreated(false), 124 m_mainMenusCreated(false),
125 m_paneMenu(0), 125 m_paneMenu(0),
126 m_layerMenu(0), 126 m_layerMenu(0),
127 m_transformsMenu(0), 127 m_transformsMenu(0),
135 m_rightButtonTransformsMenu(0), 135 m_rightButtonTransformsMenu(0),
136 m_rightButtonPlaybackMenu(0), 136 m_rightButtonPlaybackMenu(0),
137 m_soloAction(0), 137 m_soloAction(0),
138 m_soloModified(false), 138 m_soloModified(false),
139 m_prevSolo(false), 139 m_prevSolo(false),
140 m_lastInsertedMIDITime(0),
140 m_rwdStartAction(0), 141 m_rwdStartAction(0),
141 m_rwdAction(0), 142 m_rwdAction(0),
142 m_ffwdAction(0), 143 m_ffwdAction(0),
143 m_ffwdEndAction(0), 144 m_ffwdEndAction(0),
144 m_playAction(0), 145 m_playAction(0),
1664 m_playAction->setShortcut(tr("Space")); 1665 m_playAction->setShortcut(tr("Space"));
1665 m_playAction->setStatusTip(tr("Start or stop playback from the current position")); 1666 m_playAction->setStatusTip(tr("Start or stop playback from the current position"));
1666 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); 1667 connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
1667 connect(m_playSource, SIGNAL(playStatusChanged(bool)), 1668 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
1668 m_playAction, SLOT(setChecked(bool))); 1669 m_playAction, SLOT(setChecked(bool)));
1670 connect(m_playSource, SIGNAL(playStatusChanged(bool)),
1671 this, SLOT(playStatusChanged(bool)));
1669 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool))); 1672 connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool)));
1670 1673
1671 m_ffwdAction = toolbar->addAction(il.load("ffwd"), 1674 m_ffwdAction = toolbar->addAction(il.load("ffwd"),
1672 tr("Fast Forward")); 1675 tr("Fast Forward"));
1673 m_ffwdAction->setShortcut(tr("PgDown")); 1676 m_ffwdAction->setShortcut(tr("PgDown"));
3404 } 3407 }
3405 3408
3406 void 3409 void
3407 MainWindow::midiEventsAvailable() 3410 MainWindow::midiEventsAvailable()
3408 { 3411 {
3409 //!!! for now. but this won't do -- we are passing a signal/slot 3412 // This is called through a serialised signal/slot invocation
3410 //!!! connection across threads here, so timing will not be good 3413 // (across threads). It could happen quite some time after the
3411 //!!! -- we do need to use the original midi event timestamp 3414 // event was actually received, which is why event timestamping
3412 MIDIEvent ev(m_midiInput->readEvent()); 3415 // happens in the MIDI input class and not here.
3413 if (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON) { 3416 while (m_midiInput->getEventsAvailable() > 0) {
3414 insertInstant(); 3417 MIDIEvent ev(m_midiInput->readEvent());
3418 if (ev.getMessageType() != MIDIConstants::MIDI_NOTE_ON) {
3419 continue;
3420 }
3421 insertInstantAt(ev.getTime());
3415 } 3422 }
3416 } 3423 }
3424
3425 void
3426 MainWindow::playStatusChanged(bool playing)
3427 {
3428 m_lastInsertedMIDITime = -1.0; // <0 means "never during this playback"
3429 }
3417 3430
3418 void 3431 void
3419 MainWindow::layerRemoved(Layer *layer) 3432 MainWindow::layerRemoved(Layer *layer)
3420 { 3433 {
3421 setupExistingLayersMenus(); 3434 setupExistingLayersMenus();