From cb94baf6f4033b79fcb61da2de90b4d9c478d152 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 May 2008 03:11:28 +0000 Subject: [PATCH] Fix invalid error message during MIDI recording (or files with stuck notes). Handle stuck notes more gracefully in the view (probably should show up as a diamond though?). git-svn-id: svn://localhost/ardour2/branches/3.0@3359 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/canvas-note-event.h | 2 +- gtk2_ardour/midi_region_view.cc | 14 ++++++++++++-- libs/ardour/midi_model.cc | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/canvas-note-event.h b/gtk2_ardour/canvas-note-event.h index f575808bb1..776d89160d 100644 --- a/gtk2_ardour/canvas-note-event.h +++ b/gtk2_ardour/canvas-note-event.h @@ -81,7 +81,7 @@ public: virtual double x2() = 0; virtual double y2() = 0; - const boost::shared_ptr note() { return _note; } + const boost::shared_ptr note() const { return _note; } protected: enum State { None, Pressed, Dragging }; diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 2d7716ac63..a1823a4cfa 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -764,10 +764,20 @@ MidiRegionView::add_note(const boost::shared_ptr note) ev_rect->property_y2() = y1 + floor(midi_stream_view()->note_height()); if (note->duration() == 0) { - cerr << "MidiModel: WARNING: Discovered note with duration 0 and pitch " - << (int)note->note() << " at time " << note->time() << endl; + if (_active_notes) { assert(note->note() < 128); + // If this note is already active there's a stuck note, + // finish the old note rectangle + if (_active_notes[note->note()]) { + CanvasNote* const old_rect = _active_notes[note->note()]; + boost::shared_ptr old_note = old_rect->note(); + cerr << "MidiModel: WARNING: Note has duration 0: chan " << old_note->channel() + << "note " << (int)old_note->note() << " @ " << old_note->time() << endl; + /* FIXME: How large to make it? Make it a diamond? */ + old_rect->property_x2() = old_rect->property_x1() + 2.0; + old_rect->property_outline_what() = (guint32) 0xF; + } _active_notes[note->note()] = ev_rect; } /* outline all but right edge */ diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 48bb743734..462e7ba012 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -584,7 +584,6 @@ void MidiModel::append_note_off_unlocked(uint8_t chan, double time, for (WriteNotes::iterator n = _write_notes[chan].begin(); n != _write_notes[chan].end(); ++n) { Note& note = *_notes[*n].get(); - //cerr << (unsigned)(uint8_t)note.note() << " ? " << (unsigned)note_num << endl; if (note.note() == note_num) { assert(time >= note.time()); note.set_duration(time - note.time());