mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
do not crash when loading old history files with MIDI edits; add all notes in region to canvas, but pay attention to visibility
git-svn-id: svn://localhost/ardour2/branches/3.0@5652 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
7b8adc78b6
commit
2ff1cd99af
4 changed files with 44 additions and 26 deletions
|
|
@ -775,8 +775,9 @@ MidiRegionView::redisplay_model()
|
||||||
|
|
||||||
boost::shared_ptr<NoteType> note (*n);
|
boost::shared_ptr<NoteType> note (*n);
|
||||||
CanvasNoteEvent* cne;
|
CanvasNoteEvent* cne;
|
||||||
|
bool visible;
|
||||||
if (note_in_visible_range (note)) {
|
|
||||||
|
if (note_in_region_range (note, visible)) {
|
||||||
|
|
||||||
if ((cne = find_canvas_note (note)) != 0) {
|
if ((cne = find_canvas_note (note)) != 0) {
|
||||||
|
|
||||||
|
|
@ -791,11 +792,15 @@ MidiRegionView::redisplay_model()
|
||||||
update_hit (ch);
|
update_hit (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
cne->show ();
|
if (visible) {
|
||||||
|
cne->show ();
|
||||||
|
} else {
|
||||||
|
cne->hide ();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
add_note (note);
|
add_note (note, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1158,13 +1163,16 @@ MidiRegionView::play_midi_note_off(boost::shared_ptr<NoteType> note)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MidiRegionView::note_in_visible_range(const boost::shared_ptr<NoteType> note) const
|
MidiRegionView::note_in_region_range(const boost::shared_ptr<NoteType> note, bool& visible) const
|
||||||
{
|
{
|
||||||
const nframes64_t note_start_frames = beats_to_frames(note->time());
|
const nframes64_t note_start_frames = beats_to_frames(note->time());
|
||||||
bool outside = (note_start_frames - _region->start() >= _region->length())
|
|
||||||
|| (note_start_frames < _region->start())
|
bool outside = (note_start_frames - _region->start() >= _region->length()) ||
|
||||||
|| (note->note() < midi_stream_view()->lowest_note())
|
(note_start_frames < _region->start());
|
||||||
|| (note->note() > midi_stream_view()->highest_note());
|
|
||||||
|
visible = (note->note() >= midi_stream_view()->lowest_note()) &&
|
||||||
|
(note->note() <= midi_stream_view()->highest_note());
|
||||||
|
|
||||||
return !outside;
|
return !outside;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1233,7 +1241,7 @@ MidiRegionView::update_hit (CanvasHit* ev)
|
||||||
* event arrives, to properly display the note.
|
* event arrives, to properly display the note.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
MidiRegionView::add_note(const boost::shared_ptr<NoteType> note)
|
MidiRegionView::add_note(const boost::shared_ptr<NoteType> note, bool visible)
|
||||||
{
|
{
|
||||||
CanvasNoteEvent* event = 0;
|
CanvasNoteEvent* event = 0;
|
||||||
|
|
||||||
|
|
@ -1283,7 +1291,7 @@ MidiRegionView::add_note(const boost::shared_ptr<NoteType> note)
|
||||||
event->on_channel_selection_change(_last_channel_selection);
|
event->on_channel_selection_change(_last_channel_selection);
|
||||||
_events.push_back(event);
|
_events.push_back(event);
|
||||||
|
|
||||||
if (note_in_visible_range(note)) {
|
if (visible) {
|
||||||
event->show();
|
event->show();
|
||||||
} else {
|
} else {
|
||||||
event->hide ();
|
event->hide ();
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class MidiRegionView : public RegionView
|
||||||
|
|
||||||
GhostRegion* add_ghost (TimeAxisView&);
|
GhostRegion* add_ghost (TimeAxisView&);
|
||||||
|
|
||||||
void add_note(const boost::shared_ptr<NoteType> note);
|
void add_note(const boost::shared_ptr<NoteType> note, bool visible);
|
||||||
void resolve_note(uint8_t note_num, double end_time);
|
void resolve_note(uint8_t note_num, double end_time);
|
||||||
|
|
||||||
void cut_copy_clear (Editing::CutCopyOp);
|
void cut_copy_clear (Editing::CutCopyOp);
|
||||||
|
|
@ -194,8 +194,10 @@ class MidiRegionView : public RegionView
|
||||||
void move_selection(double dx, double dy);
|
void move_selection(double dx, double dy);
|
||||||
void note_dropped(ArdourCanvas::CanvasNoteEvent* ev, double d_pixels, uint8_t d_note);
|
void note_dropped(ArdourCanvas::CanvasNoteEvent* ev, double d_pixels, uint8_t d_note);
|
||||||
|
|
||||||
/** Return true iff the note is within the currently visible range */
|
/** Return true iff the note is within the extent of the region.
|
||||||
bool note_in_visible_range(const boost::shared_ptr<NoteType> note) const;
|
* @param visible will be set to true if the note is within the visible note range, false otherwise.
|
||||||
|
*/
|
||||||
|
bool note_in_region_range(const boost::shared_ptr<NoteType> note, bool& visible) const;
|
||||||
|
|
||||||
/** Get the region position in pixels relative to session. */
|
/** Get the region position in pixels relative to session. */
|
||||||
double get_position_pixels();
|
double get_position_pixels();
|
||||||
|
|
|
||||||
|
|
@ -589,8 +589,6 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||||
if (note->time() + region->position() > start + dur)
|
if (note->time() + region->position() > start + dur)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
mrv->add_note(note);
|
|
||||||
|
|
||||||
if (note->note() < _lowest_note) {
|
if (note->note() < _lowest_note) {
|
||||||
_lowest_note = note->note();
|
_lowest_note = note->note();
|
||||||
update_range = true;
|
update_range = true;
|
||||||
|
|
@ -598,6 +596,9 @@ MidiStreamView::update_rec_regions (boost::shared_ptr<MidiModel> data, nframes_t
|
||||||
_highest_note = note->note();
|
_highest_note = note->note();
|
||||||
update_range = true;
|
update_range = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mrv->add_note (note, !update_range);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mrv->extend_active_notes();
|
mrv->extend_active_notes();
|
||||||
|
|
|
||||||
|
|
@ -267,15 +267,19 @@ MidiModel::DeltaCommand::set_state(const XMLNode& delta_command)
|
||||||
|
|
||||||
_added_notes.clear();
|
_added_notes.clear();
|
||||||
XMLNode* added_notes = delta_command.child(ADDED_NOTES_ELEMENT);
|
XMLNode* added_notes = delta_command.child(ADDED_NOTES_ELEMENT);
|
||||||
XMLNodeList notes = added_notes->children();
|
if (added_notes) {
|
||||||
transform(notes.begin(), notes.end(), back_inserter(_added_notes),
|
XMLNodeList notes = added_notes->children();
|
||||||
sigc::mem_fun(*this, &DeltaCommand::unmarshal_note));
|
transform(notes.begin(), notes.end(), back_inserter(_added_notes),
|
||||||
|
sigc::mem_fun(*this, &DeltaCommand::unmarshal_note));
|
||||||
|
}
|
||||||
|
|
||||||
_removed_notes.clear();
|
_removed_notes.clear();
|
||||||
XMLNode* removed_notes = delta_command.child(REMOVED_NOTES_ELEMENT);
|
XMLNode* removed_notes = delta_command.child(REMOVED_NOTES_ELEMENT);
|
||||||
notes = removed_notes->children();
|
if (removed_notes) {
|
||||||
transform(notes.begin(), notes.end(), back_inserter(_removed_notes),
|
XMLNodeList notes = removed_notes->children();
|
||||||
sigc::mem_fun(*this, &DeltaCommand::unmarshal_note));
|
transform(notes.begin(), notes.end(), back_inserter(_removed_notes),
|
||||||
|
sigc::mem_fun(*this, &DeltaCommand::unmarshal_note));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -620,11 +624,14 @@ MidiModel::DiffCommand::set_state(const XMLNode& diff_command)
|
||||||
_changes.clear();
|
_changes.clear();
|
||||||
|
|
||||||
XMLNode* changed_notes = diff_command.child(DIFF_NOTES_ELEMENT);
|
XMLNode* changed_notes = diff_command.child(DIFF_NOTES_ELEMENT);
|
||||||
XMLNodeList notes = changed_notes->children();
|
|
||||||
|
|
||||||
transform (notes.begin(), notes.end(), back_inserter(_changes),
|
if (changed_notes) {
|
||||||
sigc::mem_fun(*this, &DiffCommand::unmarshal_change));
|
XMLNodeList notes = changed_notes->children();
|
||||||
|
|
||||||
|
transform (notes.begin(), notes.end(), back_inserter(_changes),
|
||||||
|
sigc::mem_fun(*this, &DiffCommand::unmarshal_change));
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue