Mercurial > hg > svgui
diff layer/NoteLayer.cpp @ 507:efe0f232685f
* Make it possible to record live MIDI to a note layer.
Now we're a proper MIDI sequencer. Ha, ha.
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2009 12:02:53 +0000 |
parents | 0990b95140e3 |
children | 1dd2cddc32eb |
line wrap: on
line diff
--- a/layer/NoteLayer.cpp Wed Feb 25 11:33:03 2009 +0000 +++ b/layer/NoteLayer.cpp Wed Feb 25 12:02:53 2009 +0000 @@ -1155,6 +1155,38 @@ return true; } +void +NoteLayer::addNoteOn(long frame, int pitch, int velocity) +{ + m_pendingNoteOns.insert(Note(frame, pitch, 0, float(velocity) / 127.0, "")); +} + +void +NoteLayer::addNoteOff(long frame, int pitch) +{ + for (NoteSet::iterator i = m_pendingNoteOns.begin(); + i != m_pendingNoteOns.end(); ++i) { + if (lrintf((*i).value) == pitch) { + Note note(*i); + m_pendingNoteOns.erase(i); + note.duration = frame - note.frame; + if (m_model) { + NoteModel::AddPointCommand *c = new NoteModel::AddPointCommand + (m_model, note, tr("Record Note")); + // execute and bundle: + CommandHistory::getInstance()->addCommand(c, true, true); + } + break; + } + } +} + +void +NoteLayer::abandonNoteOns() +{ + m_pendingNoteOns.clear(); +} + int NoteLayer::getDefaultColourHint(bool darkbg, bool &impose) {