From 1a8445d6a1ae5228e96cf9d681ecf39e5810ac75 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 28 Apr 2025 16:58:29 -0600 Subject: [PATCH] MidiViewBackground now has a virtual method to access instrument info --- gtk2_ardour/midi_streamview.cc | 11 +++++++++++ gtk2_ardour/midi_streamview.h | 2 ++ gtk2_ardour/midi_view_background.h | 6 ++++++ gtk2_ardour/pianoroll.cc | 12 ++++++++++++ gtk2_ardour/pianoroll.h | 2 ++ gtk2_ardour/pianoroll_background.cc | 6 ++++++ gtk2_ardour/pianoroll_background.h | 2 ++ 7 files changed, 41 insertions(+) diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index db08021337..94fb25af50 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -92,6 +92,17 @@ MidiStreamView::~MidiStreamView () undisplay_track (); } +InstrumentInfo* +MidiStreamView::instrument_info() const +{ + std::shared_ptr r = _trackview.route(); + if (!r) { + return nullptr; + } + + return &r->instrument_info(); +} + void MidiStreamView::parameter_changed (string const & param) { diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index d8c39b0206..190f8a18ff 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -89,6 +89,8 @@ public: void record_layer_check (std::shared_ptr, samplepos_t); void set_note_highlight (bool); + ARDOUR::InstrumentInfo* instrument_info() const; + protected: void setup_rec_box (); void update_rec_box (); diff --git a/gtk2_ardour/midi_view_background.h b/gtk2_ardour/midi_view_background.h index 6c4518b6a9..889d2bf882 100644 --- a/gtk2_ardour/midi_view_background.h +++ b/gtk2_ardour/midi_view_background.h @@ -35,6 +35,10 @@ #include "view_background.h" +namespace ARDOUR { + class InstrumentInfo; +} + namespace ArdourCanvas { class Item; class LineSet; @@ -117,6 +121,8 @@ class MidiViewBackground : public virtual ViewBackground virtual void set_size (double w, double h) {} PBD::Signal HeightChanged; + virtual ARDOUR::InstrumentInfo* instrument_info() const = 0; + protected: bool _range_dirty; double _range_sum_cache; diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index 8586f3f50b..b60f252578 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -490,6 +490,8 @@ Pianoroll::set_visible_channel (int n) view->set_visible_channel (n); view->swap_automation_channel (n); } + + prh->instrument_info_change (); } void @@ -3021,3 +3023,13 @@ Pianoroll::shift_midi (timepos_t const & t, bool model) view->shift_midi (t, model); } + +InstrumentInfo* +Pianoroll::instrument_info () const +{ + if (!view || !view->midi_track()) { + return nullptr; + } + + return &view->midi_track()->instrument_info (); +} diff --git a/gtk2_ardour/pianoroll.h b/gtk2_ardour/pianoroll.h index 9197fb6472..82ea8df40f 100644 --- a/gtk2_ardour/pianoroll.h +++ b/gtk2_ardour/pianoroll.h @@ -147,6 +147,8 @@ class Pianoroll : public CueEditor void shift_midi (Temporal::timepos_t const &, bool model); void make_a_region(); + ARDOUR::InstrumentInfo* instrument_info() const; + protected: void load_bindings (); void register_actions (); diff --git a/gtk2_ardour/pianoroll_background.cc b/gtk2_ardour/pianoroll_background.cc index 7168139810..156d720383 100644 --- a/gtk2_ardour/pianoroll_background.cc +++ b/gtk2_ardour/pianoroll_background.cc @@ -66,6 +66,12 @@ PianorollMidiBackground::width() const return _width; } +ARDOUR::InstrumentInfo* +PianorollMidiBackground::instrument_info () const +{ + return pianoroll.instrument_info (); +} + uint8_t PianorollMidiBackground::get_preferred_midi_channel () const { diff --git a/gtk2_ardour/pianoroll_background.h b/gtk2_ardour/pianoroll_background.h index 13f5f6abf3..c6c4eb1fc2 100644 --- a/gtk2_ardour/pianoroll_background.h +++ b/gtk2_ardour/pianoroll_background.h @@ -50,6 +50,8 @@ class PianorollMidiBackground : public MidiViewBackground void set_size (double w, double h); void set_view (MidiView*); + ARDOUR::InstrumentInfo* instrument_info() const; + protected: MidiView* view; Pianoroll& pianoroll;