diff --git a/gtk2_ardour/automation_line_base.cc b/gtk2_ardour/automation_line_base.cc index 861c4454a7..6d90744dab 100644 --- a/gtk2_ardour/automation_line_base.cc +++ b/gtk2_ardour/automation_line_base.cc @@ -111,10 +111,10 @@ AutomationLineBase::AutomationLineBase (const string& name, , _desc (desc) { group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple(0, 1.5)); - CANVAS_DEBUG_NAME (group, "region gain envelope group"); + CANVAS_DEBUG_NAME (group, "automation line group"); line = new ArdourCanvas::PolyLine (group); - CANVAS_DEBUG_NAME (line, "region gain envelope line"); + CANVAS_DEBUG_NAME (line, "automation line"); line->set_data ("line", this); line->set_data ("drag-base", _drag_base); line->set_outline_width (2.0); @@ -1036,6 +1036,8 @@ AutomationLineBase::reset_callback (const Evoral::ControlList& events) uint32_t pi = 0; uint32_t np; + std::cerr << _name << ": ALB::reset callback with " << events.size() << std::endl; + if (events.empty()) { for (vector::iterator i = control_points.begin(); i != control_points.end(); ++i) { delete *i; diff --git a/gtk2_ardour/automation_line_base.h b/gtk2_ardour/automation_line_base.h index 084d9326f3..8f78f92dab 100644 --- a/gtk2_ardour/automation_line_base.h +++ b/gtk2_ardour/automation_line_base.h @@ -23,8 +23,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __ardour_automation_line_base_h__ -#define __ardour_automation_line_base_h__ +#ifndef __gtk2_ardour_automation_line_base_h__ +#define __gtk2_ardour_automation_line_base_h__ #include #include @@ -173,6 +173,8 @@ public: double dt_to_dx (Temporal::timepos_t const &, Temporal::timecnt_t const &); + ARDOUR::ParameterDescriptor const & param() const { return _desc; } + protected: std::string _name; @@ -257,5 +259,5 @@ private: friend class RegionFxLine; }; -#endif /* __ardour_automation_line_base_h__ */ +#endif /* __gtk2_ardour_automation_line_base_h__ */ diff --git a/gtk2_ardour/midi_cue_automation_line.cc b/gtk2_ardour/midi_cue_automation_line.cc new file mode 100644 index 0000000000..73a2239b88 --- /dev/null +++ b/gtk2_ardour/midi_cue_automation_line.cc @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2005-2024 Paul Davis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "midi_cue_automation_line.h" + +MidiCueAutomationLine::MidiCueAutomationLine (const std::string& name, + EditingContext& ec, + ArdourCanvas::Item& parent, + ArdourCanvas::Rectangle* drag_base, + std::shared_ptr al, + const ARDOUR::ParameterDescriptor& desc) +: AutomationLineBase (name, ec, parent, drag_base, al, desc) +{ +} + +bool +MidiCueAutomationLine::event_handler (GdkEvent*) +{ + return true; +} diff --git a/gtk2_ardour/midi_cue_automation_line.h b/gtk2_ardour/midi_cue_automation_line.h new file mode 100644 index 0000000000..0b9895e60d --- /dev/null +++ b/gtk2_ardour/midi_cue_automation_line.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005-2024 Paul Davis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __gtk2_ardour_midi_cue_automation_line_h__ +#define __gtk2_ardour_midi_cue_automation_line_h__ + +#include "automation_line_base.h" + +class MidiCueAutomationLine : public AutomationLineBase +{ + public: + MidiCueAutomationLine (const std::string& name, + EditingContext& ec, + ArdourCanvas::Item& parent, + ArdourCanvas::Rectangle* drag_base, + std::shared_ptr al, + const ARDOUR::ParameterDescriptor& desc); + + bool event_handler (GdkEvent*); +}; + +#endif /* __gtk2_ardour_midi_cue_automation_line_base_h__ */ diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 8a131fdfc6..02fce3e0b0 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -326,8 +326,6 @@ MidiCueEditor::canvas_allocate (Gtk::Allocation alloc) _visible_canvas_width = alloc.get_width(); _visible_canvas_height = alloc.get_height(); - std::cerr << "mce allocated " << alloc.get_width() << " x " << alloc.get_width() << " view = " << view << std::endl; - if (view) { double timebars = n_timebars * timebar_height; view->set_height (alloc.get_height() - timebars); diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index 5619bbcb0d..c634cd6fd3 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -29,6 +29,7 @@ #include "editor_drag.h" #include "hit.h" #include "keyboard.h" +#include "midi_cue_automation_line.h" #include "midi_cue_view.h" #include "midi_cue_velocity.h" #include "note.h" @@ -46,6 +47,7 @@ MidiCueView::MidiCueView (std::shared_ptr mt, MidiViewBackground& bg, uint32_t basic_color) : MidiView (mt, parent, ec, bg, basic_color) + , automation_line (nullptr) , velocity_base (nullptr) , velocity_display (nullptr) , _slot_index (slot_index) @@ -79,6 +81,9 @@ MidiCueView::MidiCueView (std::shared_ptr mt, set_extensible (true); set_region (region); + + Evoral::Parameter fully_qualified_param (ARDOUR::MidiCCAutomation, 0, MIDI_CTL_MSB_MODWHEEL); + show_automation (fully_qualified_param); } void @@ -224,3 +229,63 @@ MidiCueView::update_hit (Hit* h) velocity_display->update_note (h); } } + +void +MidiCueView::show_automation (Evoral::Parameter const & param) +{ + using namespace ARDOUR; + + if (param.type() == NullAutomation) { + return; + } + +// if (automation_line && automation_line->param() == param) { +// return; +// } + + if (automation_line) { + delete automation_line; + automation_line = nullptr; + } + + std::shared_ptr control; + + switch (param.type()) { + + case MidiCCAutomation: + case MidiPgmChangeAutomation: + case MidiPitchBenderAutomation: + case MidiChannelPressureAutomation: + case MidiNotePressureAutomation: + case MidiSystemExclusiveAutomation: { + /* These controllers are region "automation" - they are owned + * by regions (and their MidiModels), not by the track. As a + * result there is no AutomationList/Line for the track, but we create + * a controller for the user to write immediate events, so the editor + * can act as a control surface for the present MIDI controllers. + * + * TODO: Record manipulation of the controller to regions? + */ + + std::shared_ptr control = _midi_region->model()->control (param, true); + std::shared_ptr ac = std::dynamic_pointer_cast (control); + + if (ac) { + std::cerr << "found control, list contains " << ac->alist()->size() << std::endl; + automation_line = new MidiCueAutomationLine ("whatevs", + _editing_context, + *automation_group, + automation_group, + ac->alist(), + ac->desc()); + automation_line->reset (); + + } + + break; + } + + default: + break; + } +} diff --git a/gtk2_ardour/midi_cue_view.h b/gtk2_ardour/midi_cue_view.h index 2659309378..e949d84036 100644 --- a/gtk2_ardour/midi_cue_view.h +++ b/gtk2_ardour/midi_cue_view.h @@ -28,6 +28,7 @@ #include "midi_view.h" class VelocityDisplay; +class MidiCueAutomationLine; class MidiCueView : public MidiView { @@ -52,12 +53,16 @@ class MidiCueView : public MidiView void ghost_add_note (NoteBase*); void ghost_sync_selection (NoteBase*); + void show_automation (Evoral::Parameter const & param); + ArdourCanvas::Item* drag_group() const; protected: bool scroll (GdkEventScroll* ev); ArdourCanvas::Rectangle* automation_group; + MidiCueAutomationLine* automation_line; + ArdourCanvas::Rectangle* velocity_base; VelocityDisplay* velocity_display; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 6d0bbeebfe..afb17f2e82 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -160,6 +160,7 @@ gtk2_ardour_sources = [ 'midi_automation_line.cc', 'midi_channel_dialog.cc', 'midi_channel_selector.cc', + 'midi_cue_automation_line.cc', 'midi_cue_background.cc', 'midi_cue_editor.cc', 'midi_cue_velocity.cc',