Mercurial > hg > sonic-visualiser
changeset 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 |
files | main/MainWindow.cpp main/MainWindow.h |
diffstat | 2 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Tue Feb 24 17:53:01 2009 +0000 +++ b/main/MainWindow.cpp Wed Feb 25 11:15:22 2009 +0000 @@ -119,7 +119,7 @@ MainWindow::MainWindow(bool withAudioOutput, bool withOSCSupport) : - MainWindowBase(withAudioOutput, withOSCSupport), + MainWindowBase(withAudioOutput, withOSCSupport, true), m_overview(0), m_mainMenusCreated(false), m_paneMenu(0), @@ -137,6 +137,7 @@ m_soloAction(0), m_soloModified(false), m_prevSolo(false), + m_lastInsertedMIDITime(0), m_rwdStartAction(0), m_rwdAction(0), m_ffwdAction(0), @@ -1666,6 +1667,8 @@ connect(m_playAction, SIGNAL(triggered()), this, SLOT(play())); connect(m_playSource, SIGNAL(playStatusChanged(bool)), m_playAction, SLOT(setChecked(bool))); + connect(m_playSource, SIGNAL(playStatusChanged(bool)), + this, SLOT(playStatusChanged(bool))); connect(this, SIGNAL(canPlay(bool)), m_playAction, SLOT(setEnabled(bool))); m_ffwdAction = toolbar->addAction(il.load("ffwd"), @@ -3406,16 +3409,26 @@ void MainWindow::midiEventsAvailable() { - //!!! for now. but this won't do -- we are passing a signal/slot - //!!! connection across threads here, so timing will not be good - //!!! -- we do need to use the original midi event timestamp - MIDIEvent ev(m_midiInput->readEvent()); - if (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON) { - insertInstant(); + // This is called through a serialised signal/slot invocation + // (across threads). It could happen quite some time after the + // event was actually received, which is why event timestamping + // happens in the MIDI input class and not here. + while (m_midiInput->getEventsAvailable() > 0) { + MIDIEvent ev(m_midiInput->readEvent()); + if (ev.getMessageType() != MIDIConstants::MIDI_NOTE_ON) { + continue; + } + insertInstantAt(ev.getTime()); } } void +MainWindow::playStatusChanged(bool playing) +{ + m_lastInsertedMIDITime = -1.0; // <0 means "never during this playback" +} + +void MainWindow::layerRemoved(Layer *layer) { setupExistingLayersMenus();
--- a/main/MainWindow.h Tue Feb 24 17:53:01 2009 +0000 +++ b/main/MainWindow.h Wed Feb 25 11:15:22 2009 +0000 @@ -166,6 +166,7 @@ virtual void handleOSCMessage(const OSCMessage &); virtual void midiEventsAvailable(); + virtual void playStatusChanged(bool); virtual void website(); virtual void help(); @@ -205,6 +206,8 @@ bool m_soloModified; bool m_prevSolo; + double m_lastInsertedMIDITime; + QFrame *m_playControlsSpacer; int m_playControlsWidth;