From b874bbfbf0236c1dc489dd52c4dbebe523a5f916 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 28 Apr 2025 16:58:57 -0600 Subject: [PATCH] use instrument info for note names in pianoroll (canvas-based) header --- gtk2_ardour/prh.cc | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/prh.cc b/gtk2_ardour/prh.cc index 7807707274..d2e5b4d2b0 100644 --- a/gtk2_ardour/prh.cc +++ b/gtk2_ardour/prh.cc @@ -25,6 +25,7 @@ #include "canvas/canvas.h" +#include "ardour/instrument_info.h" #include "ardour/midi_track.h" #include "gtkmm2ext/colors.h" @@ -550,27 +551,20 @@ PianoRollHeader::get_note_name (int note) std::string note_n; NoteName rtn; -#if 0 - MidiTimeAxisView* mtv = dynamic_cast(&_view.trackview()); + ARDOUR::InstrumentInfo* ii = _midi_context.instrument_info(); - if (mtv) { - string chn = mtv->gui_property (X_("midnam-channel")); - - if (!chn.empty()) { - - int midnam_channel; - - sscanf (chn.c_str(), "%*s %d", &midnam_channel); - midnam_channel--; - - name = mtv->route()->instrument_info ().get_note_name ( - 0, //bank - 0, //program - midnam_channel, //channel - note); //note - } + if (!ii) { + return rtn; } + int midnam_channel = _midi_context.get_preferred_midi_channel (); + + name = ii->get_note_name ( + 0, //bank + 0, //program + midnam_channel, //channel + note); //note + int oct_rel = note % 12; switch (oct_rel) { case 0: @@ -613,7 +607,6 @@ PianoRollHeader::get_note_name (int note) break; } -#endif std::string new_string = std::string(3 - std::to_string(note).length(), '0') + std::to_string(note); rtn.name = name.empty()? new_string + " " + note_n : name; rtn.from_midnam = !name.empty();