diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 2fd6b71960..b04b8bda81 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -318,11 +318,12 @@ MidiCueEditor::maybe_update () } if (_track->rec_enable_control()->get_value()) { - /* data recorded will handle it */ + /* ::data_captured() will handle it */ return; } ARDOUR::TriggerPtr trigger = _track->triggerbox()->currently_playing (); + if (!trigger) { _playhead_cursor->set_position (0); } else { @@ -503,14 +504,24 @@ MidiCueEditor::set_box (std::shared_ptr b) b->Captured.connect (capture_connections, invalidator (*this), boost::bind (&MidiCueEditor::data_captured, this, _1), gui_context()); /* Don't bind a shared_ptr within the lambda */ TriggerBox* tb (b.get()); - b->RecEnableChanged.connect (capture_connections, invalidator (*this), [&, tb]() { rec_enable_change (tb); }, gui_context()); + b->RecEnableChanged.connect (capture_connections, invalidator (*this), [&, tb]() { box_rec_enable_change (*tb); }, gui_context()); } } void -MidiCueEditor::rec_enable_change (ARDOUR::TriggerBox* b) +MidiCueEditor::box_rec_enable_change (ARDOUR::TriggerBox const & b) { - if (b->record_enabled()) { + if (b.record_enabled()) { + view->begin_write(); + } else { + view->end_write (); + } +} + +void +MidiCueEditor::trigger_rec_enable_change (ARDOUR::Trigger const & t) +{ + if (t.armed()) { view->begin_write(); } else { view->end_write (); diff --git a/gtk2_ardour/midi_cue_editor.h b/gtk2_ardour/midi_cue_editor.h index 637815011c..c541e7175e 100644 --- a/gtk2_ardour/midi_cue_editor.h +++ b/gtk2_ardour/midi_cue_editor.h @@ -86,6 +86,9 @@ class MidiCueEditor : public CueEditor Editing::MouseMode current_mouse_mode () const; bool internal_editing() const; + void box_rec_enable_change (ARDOUR::TriggerBox const &); + void trigger_rec_enable_change (ARDOUR::Trigger const &); + double timebar_height; size_t n_timebars; @@ -211,7 +214,6 @@ class MidiCueEditor : public CueEditor void visual_changer (const VisualChange&); void bindings_changed (); - void rec_enable_change (ARDOUR::TriggerBox*); void data_captured (Temporal::timecnt_t); bool idle_data_captured (); std::atomic idle_update_queued; diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 84ec2cacc3..5e5f86e561 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -1560,9 +1560,8 @@ MidiView::apply_note_range (uint8_t min, uint8_t max, bool force) void MidiView::begin_write() { - std::cerr << "MV::begin write\n"; if (_active_notes) { - delete[] _active_notes; + delete [] _active_notes; } _active_notes = new Note*[128]; for (unsigned i = 0; i < 128; ++i) { @@ -1577,7 +1576,6 @@ MidiView::begin_write() void MidiView::end_write() { - std::cerr << "MV::end write\n"; delete [] _active_notes; _active_notes = nullptr; _marked_for_selection.clear(); diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index c923233df6..647d96d070 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -386,6 +386,13 @@ TriggerPage::clear_selected_slot () void TriggerPage::rec_enable_changed (Trigger const * trigger) { + assert (trigger); + + if (!trigger->armed()) { + _midi_editor->trigger_rec_enable_change (*trigger); + return; + } + /* hide everything */ _slot_prop_box.hide (); @@ -406,7 +413,9 @@ TriggerPage::rec_enable_changed (Trigger const * trigger) _audio_trig_box.set_trigger (ref); _audio_trig_box.show (); } + } else { + _midi_trig_box.set_trigger (ref); _midi_trig_box.show ();