Skip to content

Commit

Permalink
some work on being able to swap channels and have different MIDI auto…
Browse files Browse the repository at this point in the history
…mation displayed in pianoroll
  • Loading branch information
pauldavisthefirst committed Dec 20, 2024
1 parent 5248e81 commit 084a23a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gtk2_ardour/editor_drag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7476,8 +7476,10 @@ AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured)
FreehandLineDrag<Evoral::ControlList::OrderedPoints,Evoral::ControlList::OrderedPoint>::finished (event, motion_occured);

MergeableLine* ml = lm->make_merger();
ml->merge_drawn_line (editing_context, *editing_context.session(), drawn_points, !did_snap);
delete ml;
if (ml) {
ml->merge_drawn_line (editing_context, *editing_context.session(), drawn_points, !did_snap);
delete ml;
}
}

/*****************/
Expand Down
4 changes: 4 additions & 0 deletions gtk2_ardour/midi_cue_editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ MidiCueEditor::set_visible_channel (int n)
{
_visible_channel = n;
visible_channel_label.set_text (string_compose (_("MIDI Channel %1"), _visible_channel + 1));

if (view) {
view->swap_automation_channel (n);
}
}

void
Expand Down
37 changes: 37 additions & 0 deletions gtk2_ardour/midi_cue_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,43 @@ MidiCueView::update_hit (Hit* h)
}
}

void
MidiCueView::swap_automation_channel (int new_channel)
{
std::vector<Evoral::Parameter> new_params;
Evoral::Parameter active (0, 0, 0);
bool have_active = false;

/* Make a note of what was visible, but use the new channel */

for (CueAutomationMap::iterator i = automation_map.begin(); i != automation_map.end(); ++i) {
if (i->second.visible) {
Evoral::Parameter param (i->first.type(), new_channel, i->first.id());
new_params.push_back (param);
if (&i->second == active_automation) {
active = param;
have_active = true;
}
}
}

/* Drop the old */

automation_map.clear ();

/* Create the new */

for (auto const & p : new_params) {
update_automation_display (p, SelectionAdd);
}

if (have_active) {
set_active_automation (active);
} else {
unset_active_automation ();
}
}

void
MidiCueView::update_automation_display (Evoral::Parameter const & param, SelectionOperation op)
{
Expand Down
1 change: 1 addition & 0 deletions gtk2_ardour/midi_cue_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class MidiCueView : public MidiView
void ghost_sync_selection (NoteBase*);

void update_automation_display (Evoral::Parameter const & param, ARDOUR::SelectionOperation);
void swap_automation_channel (int);
void set_active_automation (Evoral::Parameter const &);
bool is_active_automation (Evoral::Parameter const &) const;
bool is_visible_automation (Evoral::Parameter const &) const;
Expand Down

0 comments on commit 084a23a

Please sign in to comment.