From 24f574772e361773c3b2656dea05d2338ec1a2ed Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 21 Jun 2024 01:52:12 +0200 Subject: [PATCH 1/8] Hide coverage frame when dragging layered region #9725 --- gtk2_ardour/audio_region_view.cc | 2 +- gtk2_ardour/editor_drag.cc | 3 ++- gtk2_ardour/region_view.cc | 21 ++++++++++++++++----- gtk2_ardour/region_view.h | 4 ++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index ace81da8e5..9a9eaa4346 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -1914,7 +1914,7 @@ AudioRegionView::show_xfades () void AudioRegionView::drag_start () { - TimeAxisViewItem::drag_start (); + RegionView::drag_start (); //we used to hide xfades here. I don't see the point with the new model, but we can re-implement if needed } diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 37a2c6f90e..6dbe783885 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2795,11 +2795,12 @@ TrimDrag::motion (GdkEvent* event, bool first_move) rv->trim_front_starting (); } + rv->drag_start (); + AudioRegionView* const arv = dynamic_cast (rv); if (arv) { arv->temporarily_hide_envelope (); - arv->drag_start (); } std::shared_ptr pl = rv->region ()->playlist (); diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 7ce3fea02c..58d7abe2db 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -963,17 +963,28 @@ RegionView::set_height (double h) } } +void +RegionView::drag_start () +{ + clear_coverage_frame (); +} + +void +RegionView::clear_coverage_frame () +{ + for (auto& i : _coverage_frame) { + delete i; + } + _coverage_frame.clear (); +} + /** Remove old coverage frame and make new ones, if we're in a LayerDisplay mode * which uses them. */ void RegionView::update_coverage_frame (LayerDisplay d) { /* remove old coverage frame */ - for (auto& i : _coverage_frame) { - delete i; - } - - _coverage_frame.clear (); + clear_coverage_frame (); if (d != Stacked) { /* don't do coverage frame unless we're in stacked mode */ diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index d4b73cff29..33f8519da4 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -86,6 +86,8 @@ public: void raise_to_top (); void lower_to_bottom (); + void drag_start (); + bool set_position(Temporal::timepos_t const & pos, void* src, double* delta = 0); virtual void show_region_editor (); @@ -238,6 +240,8 @@ private: void update_cue_markers (); + void clear_coverage_frame (); + struct ViewCueMarker { ArdourMarker* view_marker; ARDOUR::CueMarker model_marker; From 44d01f59518de6831bc3173e7babc0a13251e1a5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 21 Jun 2024 17:36:28 +0200 Subject: [PATCH 2/8] Update coverage frame while timming regions #9725 --- gtk2_ardour/editor_drag.cc | 14 ++++++++++++-- gtk2_ardour/region_view.cc | 6 ------ gtk2_ardour/region_view.h | 2 -- gtk2_ardour/streamview.h | 4 +--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 6dbe783885..26c0b72193 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -2876,10 +2876,13 @@ TrimDrag::motion (GdkEvent* event, bool first_move) } } + bool changed = false; + switch (_operation) { case StartTrim: for (list::iterator i = _views.begin (); i != _views.end (); ++i) { - bool changed = i->view->trim_front (timepos_t (i->initial_position) + dt, non_overlap_trim); + changed = i->view->trim_front (timepos_t (i->initial_position) + dt, non_overlap_trim); + if (changed && _preserve_fade_anchor) { AudioRegionView* arv = dynamic_cast (i->view); @@ -2900,7 +2903,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) case EndTrim: for (list::iterator i = _views.begin (); i != _views.end (); ++i) { - bool changed = i->view->trim_end (timepos_t (i->initial_end) + dt, non_overlap_trim); + changed = i->view->trim_end (timepos_t (i->initial_end) + dt, non_overlap_trim); if (changed && _preserve_fade_anchor) { AudioRegionView* arv = dynamic_cast (i->view); @@ -2918,6 +2921,13 @@ TrimDrag::motion (GdkEvent* event, bool first_move) break; } + if (changed) { + for (list::const_iterator i = _views.begin (); i != _views.end (); ++i) { + StreamView* sv = i->view->get_time_axis_view ().view (); + sv->update_coverage_frame (); + } + } + switch (_operation) { case StartTrim: show_verbose_cursor_time (rv->region ()->position ()); diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 58d7abe2db..76f06391d7 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -963,12 +963,6 @@ RegionView::set_height (double h) } } -void -RegionView::drag_start () -{ - clear_coverage_frame (); -} - void RegionView::clear_coverage_frame () { diff --git a/gtk2_ardour/region_view.h b/gtk2_ardour/region_view.h index 33f8519da4..057c2810fa 100644 --- a/gtk2_ardour/region_view.h +++ b/gtk2_ardour/region_view.h @@ -86,8 +86,6 @@ public: void raise_to_top (); void lower_to_bottom (); - void drag_start (); - bool set_position(Temporal::timepos_t const & pos, void* src, double* delta = 0); virtual void show_region_editor (); diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 5584dd00c6..024551f96c 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -126,6 +126,7 @@ public: void check_record_layers (std::shared_ptr, ARDOUR::samplepos_t); virtual void playlist_layered (std::weak_ptr); + void update_coverage_frame (); sigc::signal RegionViewAdded; sigc::signal RegionViewRemoved; @@ -193,9 +194,6 @@ protected: */ samplepos_t _new_rec_layer_time; void setup_new_rec_layer_time (std::shared_ptr); - -private: - void update_coverage_frame (); }; #endif /* __ardour_streamview_h__ */ From 10cd3c85cda6279710ee7182a30d383a40af5fc1 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 20 Jun 2024 21:20:22 -0600 Subject: [PATCH 3/8] when delivering a MIDI scene change, ensure trace parser sees the data --- libs/ardour/midi_scene_changer.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index 505c7fec8c..13df7713d5 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -102,14 +102,23 @@ MIDISceneChanger::rt_deliver (MidiBuffer& mbuf, samplepos_t when, std::shared_pt uint8_t buf[4]; size_t cnt; + std::shared_ptr aport = std::dynamic_pointer_cast(output_port); + MIDI::Parser* parser (aport ? aport->parser() : output_port->trace_parser().get()); MIDIOutputActivity (); /* EMIT SIGNAL */ if ((cnt = msc->get_bank_msb_message (buf, sizeof (buf))) > 0) { mbuf.push_back (when, Evoral::MIDI_EVENT, cnt, buf); + for (size_t n = 0; parser && n < cnt; ++n) { + parser->scanner (buf[n]); + } + if ((cnt = msc->get_bank_lsb_message (buf, sizeof (buf))) > 0) { mbuf.push_back (when, Evoral::MIDI_EVENT, cnt, buf); + for (size_t n = 0; parser && n < cnt; ++n) { + parser->scanner (buf[n]); + } } last_delivered_bank = msc->bank(); @@ -117,7 +126,9 @@ MIDISceneChanger::rt_deliver (MidiBuffer& mbuf, samplepos_t when, std::shared_pt if ((cnt = msc->get_program_message (buf, sizeof (buf))) > 0) { mbuf.push_back (when, Evoral::MIDI_EVENT, cnt, buf); - + for (size_t n = 0; parser && n < cnt; ++n) { + parser->scanner (buf[n]); + } last_delivered_program = msc->program(); } } From f54fd286ee7c3672d1fc68ffbdd603ec21a804b9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Jun 2024 12:49:19 -0600 Subject: [PATCH 4/8] MIDI scene changes should use bank 0 if no bank msg has been seen --- libs/ardour/midi_scene_changer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index 13df7713d5..d785d016bc 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -335,7 +335,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program new_mark = true; } - int bank = -1; + int bank = 0; if (have_seen_bank_changes) { bank = std::dynamic_pointer_cast(input_port)->channel (channel)->bank(); } From d7f9b659f2903af40877a5372048b0c3bbf0966b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Jun 2024 12:49:58 -0600 Subject: [PATCH 5/8] slightly improve mgmt of shared_ptr --- libs/ardour/midi_scene_changer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index d785d016bc..18c01632a5 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -340,7 +340,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program bank = std::dynamic_pointer_cast(input_port)->channel (channel)->bank(); } - MIDISceneChange* msc =new MIDISceneChange (channel, bank, program & 0x7f); + std::shared_ptr msc (new MIDISceneChange (channel, bank, program & 0x7f)); /* check for identical scene change so we can re-use color, if any */ From af9472ecb60d4a1c6f684c1e455f2e9907715ca2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Jun 2024 12:50:28 -0600 Subject: [PATCH 6/8] fix naming of MIDI scene changes Or at least make the arithmetic precedence clearer --- libs/ardour/midi_scene_changer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index 18c01632a5..687260af83 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -355,8 +355,8 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program } } - loc->set_scene_change (std::shared_ptr (msc)); - loc->set_name( string_compose(_("scene [%1]"), 1+bank*128+(program & 0x7f))); + loc->set_scene_change (msc); + loc->set_name (string_compose(_("scene [%1]"), 1 + ((bank*128)+(program & 0x7f)))); /* this will generate a "changed" signal to be emitted by locations, and we will call ::gather() to update our list of MIDI events. From bbcaf617c4336e479ed33ab3ba96a63e3ec9aca3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Jun 2024 12:51:28 -0600 Subject: [PATCH 7/8] async MIDI ports run output trace parser scanner if there is one --- libs/ardour/async_midi_port.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index 0b38f0966c..7c4effa620 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -231,9 +231,14 @@ AsyncMIDIPort::write (const MIDI::byte * msg, size_t msglen, MIDI::timestamp_t t * delivered */ + std::shared_ptr tp (trace_parser()); + _parser->set_timestamp (AudioEngine::instance()->sample_time() + timestamp); for (size_t n = 0; n < msglen; ++n) { _parser->scanner (msg[n]); + if (tp) { + tp->scanner (msg[n]); + } } Glib::Threads::Mutex::Lock lm (output_fifo_lock); From df7fe4fb917414263515de9486fe398272c92c29 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 21 Jun 2024 13:58:30 -0600 Subject: [PATCH 8/8] MIDI tracer: don't update ports if audio engine is not running when ports_changed() is called --- gtk2_ardour/midi_tracer.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index 22ae957ed7..1b31b0a783 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -166,6 +166,10 @@ MidiTracer::ports_changed () _midi_port_list->clear (); + if (!AudioEngine::instance()->running()) { + return; + } + PortManager::PortList pl; AudioEngine::instance()->get_ports (DataType::MIDI, pl);