return 0;
}
+boost::shared_ptr<PatchChange>
+MidiRegionView::find_canvas_patch_change (MidiModel::PatchChangePtr p)
+{
+ for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
+ if ((*x)->patch() == p) {
+ return (*x);
+ }
+ }
+
+ return 0;
+}
+
void
MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask)
{
}
}
- _patch_changes.clear();
_sys_exes.clear();
display_sysexes();
MidiRegionView::display_patch_changes_on_channel (uint8_t channel, bool active_channel)
{
for (MidiModel::PatchChanges::const_iterator i = _model->patch_changes().begin(); i != _model->patch_changes().end(); ++i) {
+ boost::shared_ptr<PatchChange> p;
if ((*i)->channel() != channel) {
continue;
}
- const string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel);
- add_canvas_patch_change (*i, patch_name, active_channel);
+ if ((p = find_canvas_patch_change (*i)) != 0) {
+ framecnt_t region_frames = source_beats_to_region_frames ((*i)->time());
+ const double x = trackview.editor().sample_to_pixel (region_frames);
+ p->canvas_item()->set_position (ArdourCanvas::Duple (x, 1.0));
+ } else {
+ const string patch_name = instrument_info().get_patch_name ((*i)->bank(), (*i)->program(), channel);
+ add_canvas_patch_change (*i, patch_name, active_channel);
+ }
}
}
_patch_changes.push_back (patch_change);
}
+void
+MidiRegionView::remove_canvas_patch_change (PatchChange* pc)
+{
+ /* remove the canvas item */
+ for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
+ if ((*x)->patch() == pc->patch()) {
+ _patch_changes.erase (x);
+ break;
+ }
+ }
+}
+
MIDI::Name::PatchPrimaryKey
MidiRegionView::patch_change_to_patch_key (MidiModel::PatchChangePtr p)
{
{
string name = _("alter patch change");
trackview.editor().begin_reversible_command (name);
+
+ remove_canvas_patch_change (&pc);
+
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (name);
if (pc.patch()->program() != new_patch.program()) {
_model->apply_command (*trackview.session(), c);
trackview.editor().commit_reversible_command ();
- _patch_changes.clear ();
display_patch_changes ();
}
trackview.editor().begin_reversible_command (name);
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (name);
+ for (PatchChanges::iterator x = _patch_changes.begin(); x != _patch_changes.end(); ++x) {
+ if ((*x)->patch() == old_change) {
+ _patch_changes.erase (x);
+ break;
+ }
+ }
+
if (old_change->time() != new_change.time()) {
c->change_time (old_change, new_change.time());
}
_model->apply_command (*trackview.session(), c);
trackview.editor().commit_reversible_command ();
- _patch_changes.clear ();
display_patch_changes ();
}
_model->apply_command (*trackview.session(), c);
trackview.editor().commit_reversible_command ();
- _patch_changes.clear ();
display_patch_changes ();
}
_model->apply_command (*trackview.session(), c);
trackview.editor().commit_reversible_command ();
- _patch_changes.clear ();
display_patch_changes ();
}
MidiRegionView::delete_patch_change (PatchChange* pc)
{
trackview.editor().begin_reversible_command (_("delete patch change"));
+
+ remove_canvas_patch_change (pc);
+
MidiModel::PatchChangeDiffCommand* c = _model->new_patch_change_diff_command (_("delete patch change"));
c->remove (pc->patch ());
_model->apply_command (*trackview.session(), c);
trackview.editor().commit_reversible_command ();
- _patch_changes.clear ();
display_patch_changes ();
}
void paste_internal (framepos_t pos, unsigned paste_count, float times, const MidiCutBuffer&);
void add_canvas_patch_change (ARDOUR::MidiModel::PatchChangePtr patch, const std::string& displaytext, bool);
+ void remove_canvas_patch_change (PatchChange* pc);
/** Look up the given time and channel in the 'automation' and set keys accordingly.
* @param time the time of the patch change event
NoteBase* find_canvas_note (Evoral::event_id_t id);
Events::iterator _optimization_iterator;
+ boost::shared_ptr<PatchChange> find_canvas_patch_change (ARDOUR::MidiModel::PatchChangePtr p);
+
void update_note (NoteBase*, bool update_ghost_regions = true);
void update_sustained (Note *, bool update_ghost_regions = true);
void update_hit (Hit *, bool update_ghost_regions = true);