diff --git a/gtk2_ardour/ardour.bindings.in b/gtk2_ardour/ardour.bindings.in index bbe72c0578..e8a918cb1f 100644 --- a/gtk2_ardour/ardour.bindings.in +++ b/gtk2_ardour/ardour.bindings.in @@ -211,6 +211,7 @@ ; (gtk_accel_path "/Main/AudioFileFormat" "") ; (gtk_accel_path "/Transport/Transport" "") (gtk_accel_path "/MouseMode/set-mouse-mode-timefx" "t") +(gtk_accel_path "/MouseMode/set-mouse-mode-note" "n") ; (gtk_accel_path "/RegionList/SortByRegionName" "") ; (gtk_accel_path "/Main/KeyMouse Actions" "") (gtk_accel_path "/MouseMode/set-mouse-mode-gain" "g") diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index b66e2d3986..24adba9f7f 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -140,6 +140,7 @@ + diff --git a/libs/ardour/ardour/midi_model.h b/libs/ardour/ardour/midi_model.h index 36c5fe1212..674de0c1d0 100644 --- a/libs/ardour/ardour/midi_model.h +++ b/libs/ardour/ardour/midi_model.h @@ -118,7 +118,9 @@ private: Session& _session; Notes _notes; - Notes _write_notes; + + typedef std::vector WriteNotes; + WriteNotes _write_notes; MidiEditCommand* _command; ///< In-progress command }; diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 2d4a44d437..27b0c4835e 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -59,17 +59,17 @@ void MidiModel::end_write(bool delete_stuck) { if (delete_stuck) { - _write_notes.clear(); - } else { - cerr << "FIXME: Stuck notes lost" << endl; - _write_notes.clear(); - /* Merge _write_events into _events */ - /*size_t ev_index = 0 - size_t write_index = 0; - while ( ! _write_events.empty()) { - // do stuff - }*/ + for (Notes::iterator n = _notes.begin(); n != _notes.end() ; ) { + if (n->duration == 0) { + cerr << "WARNING: Stuck note lost: " << n->note << endl; + n = _notes.erase(n); + } else { + ++n; + } + } } + + _write_notes.clear(); } @@ -87,7 +87,7 @@ MidiModel::append(const MidiBuffer& buf) for (size_t i=0; i < buf.size(); ++i) { const MidiEvent& ev = buf[i]; - assert(_write_notes.empty() || ev.time >= _write_notes.back().start); + assert(_notes.empty() || ev.time >= _notes.back().start); if (ev.type() == MIDI_CMD_NOTE_ON) append_note_on(ev.time, ev.note(), ev.velocity()); @@ -106,7 +106,7 @@ MidiModel::append(const MidiBuffer& buf) void MidiModel::append(double time, size_t size, Byte* buf) { - assert(_write_notes.empty() || time >= _write_notes.back().start); + assert(_notes.empty() || time >= _notes.back().start); if ((buf[0] & 0xF0) == MIDI_CMD_NOTE_ON) append_note_on(time, buf[1], buf[2]); @@ -116,9 +116,10 @@ MidiModel::append(double time, size_t size, Byte* buf) void -MidiModel::append_note_on(double time, uint8_t note, uint8_t velocity) +MidiModel::append_note_on(double time, uint8_t note_num, uint8_t velocity) { - _write_notes.push_back(Note(time, 0, note, velocity)); + _notes.push_back(Note(time, 0, note_num, velocity)); + _write_notes.push_back(_notes.size() - 1); } @@ -132,12 +133,13 @@ MidiModel::append_note_off(double time, uint8_t note_num) /* FIXME: note off velocity for that one guy out there who actually has * keys that send it */ - for (size_t i=0; i < _write_notes.size(); ++i) { - Note& note = _write_notes[i]; + for (WriteNotes::iterator n = _write_notes.begin(); n != _write_notes.end(); ++n) { + Note& note = _notes[*n]; if (note.note == note_num) { assert(time > note.start); note.duration = time - note.start; - cerr << "MidiModel resolved note, duration: " << note.duration << endl; + _write_notes.erase(n); + //cerr << "MidiModel resolved note, duration: " << note.duration << endl; break; } } diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index e7ae4a3239..394a6f103f 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -176,7 +176,7 @@ SMFSource::flush_header () { // FIXME: write timeline position somehow? - cerr << "SMF Flushing header\n"; + //cerr << "SMF Flushing header\n"; assert(_fd); @@ -205,7 +205,7 @@ SMFSource::flush_header () int SMFSource::flush_footer() { - cerr << "SMF - Writing EOT\n"; + //cerr << "SMF - Writing EOT\n"; fseek(_fd, 0, SEEK_END); write_var_len(1); // whatever...