# HG changeset patch # User Chris Cannam # Date 1235669626 0 # Node ID 6a276fea550dcf0291142f4369db5422014834cc # Parent 4ad11b1cf05007683d2914d119e0594716ff7dc5 * If a time-value layer is current when a midi note event is received, place points in it with values based on the midi note pitch class diff -r 4ad11b1cf050 -r 6a276fea550d main/MainWindow.cpp --- a/main/MainWindow.cpp Thu Feb 26 10:49:08 2009 +0000 +++ b/main/MainWindow.cpp Thu Feb 26 17:33:46 2009 +0000 @@ -3431,11 +3431,14 @@ { Pane *currentPane = 0; NoteLayer *currentNoteLayer = 0; + TimeValueLayer *currentTimeValueLayer = 0; if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); if (currentPane) { currentNoteLayer = dynamic_cast (currentPane->getSelectedLayer()); + currentTimeValueLayer = dynamic_cast + (currentPane->getSelectedLayer()); } // This is called through a serialised signal/slot invocation @@ -3447,6 +3450,8 @@ MIDIEvent ev(m_midiInput->readEvent()); + size_t frame = currentPane->alignFromReference(ev.getTime()); + bool noteOn = (ev.getMessageType() == MIDIConstants::MIDI_NOTE_ON && ev.getVelocity() > 0); @@ -3458,22 +3463,39 @@ if (noteOn) { - currentNoteLayer->addNoteOn(ev.getTime(), + currentNoteLayer->addNoteOn(frame, ev.getPitch(), ev.getVelocity()); } else if (noteOff) { - currentNoteLayer->addNoteOff(ev.getTime(), + currentNoteLayer->addNoteOff(frame, ev.getPitch()); } - } else { + continue; + } + + if (currentTimeValueLayer) { if (!noteOn) continue; - insertInstantAt(ev.getTime()); + Model *model = static_cast(currentTimeValueLayer)->getModel(); + SparseTimeValueModel *tvm = + dynamic_cast(model); + if (tvm) { + SparseTimeValueModel::Point point(frame, ev.getPitch() % 12, ""); + SparseTimeValueModel::AddPointCommand *command = + new SparseTimeValueModel::AddPointCommand + (tvm, point, tr("Add Point")); + CommandHistory::getInstance()->addCommand(command); + } + continue; + } + + if (!noteOn) continue; + insertInstantAt(ev.getTime()); } }