kinda-sorta get an automation line for modwheel in the cue editor

This commit is contained in:
Paul Davis 2024-09-18 22:05:02 -06:00
parent afa15a0061
commit 71d5b50a94
8 changed files with 152 additions and 7 deletions

View file

@ -111,10 +111,10 @@ AutomationLineBase::AutomationLineBase (const string& name,
, _desc (desc) , _desc (desc)
{ {
group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple(0, 1.5)); 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); 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 ("line", this);
line->set_data ("drag-base", _drag_base); line->set_data ("drag-base", _drag_base);
line->set_outline_width (2.0); line->set_outline_width (2.0);
@ -1036,6 +1036,8 @@ AutomationLineBase::reset_callback (const Evoral::ControlList& events)
uint32_t pi = 0; uint32_t pi = 0;
uint32_t np; uint32_t np;
std::cerr << _name << ": ALB::reset callback with " << events.size() << std::endl;
if (events.empty()) { if (events.empty()) {
for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) { for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) {
delete *i; delete *i;

View file

@ -23,8 +23,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#ifndef __ardour_automation_line_base_h__ #ifndef __gtk2_ardour_automation_line_base_h__
#define __ardour_automation_line_base_h__ #define __gtk2_ardour_automation_line_base_h__
#include <vector> #include <vector>
#include <list> #include <list>
@ -173,6 +173,8 @@ public:
double dt_to_dx (Temporal::timepos_t const &, Temporal::timecnt_t const &); double dt_to_dx (Temporal::timepos_t const &, Temporal::timecnt_t const &);
ARDOUR::ParameterDescriptor const & param() const { return _desc; }
protected: protected:
std::string _name; std::string _name;
@ -257,5 +259,5 @@ private:
friend class RegionFxLine; friend class RegionFxLine;
}; };
#endif /* __ardour_automation_line_base_h__ */ #endif /* __gtk2_ardour_automation_line_base_h__ */

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2005-2024 Paul Davis <paul@linuxaudiosystems.com>
*
* 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<ARDOUR::AutomationList> al,
const ARDOUR::ParameterDescriptor& desc)
: AutomationLineBase (name, ec, parent, drag_base, al, desc)
{
}
bool
MidiCueAutomationLine::event_handler (GdkEvent*)
{
return true;
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 2005-2024 Paul Davis <paul@linuxaudiosystems.com>
*
* 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<ARDOUR::AutomationList> al,
const ARDOUR::ParameterDescriptor& desc);
bool event_handler (GdkEvent*);
};
#endif /* __gtk2_ardour_midi_cue_automation_line_base_h__ */

View file

@ -326,8 +326,6 @@ MidiCueEditor::canvas_allocate (Gtk::Allocation alloc)
_visible_canvas_width = alloc.get_width(); _visible_canvas_width = alloc.get_width();
_visible_canvas_height = alloc.get_height(); _visible_canvas_height = alloc.get_height();
std::cerr << "mce allocated " << alloc.get_width() << " x " << alloc.get_width() << " view = " << view << std::endl;
if (view) { if (view) {
double timebars = n_timebars * timebar_height; double timebars = n_timebars * timebar_height;
view->set_height (alloc.get_height() - timebars); view->set_height (alloc.get_height() - timebars);

View file

@ -29,6 +29,7 @@
#include "editor_drag.h" #include "editor_drag.h"
#include "hit.h" #include "hit.h"
#include "keyboard.h" #include "keyboard.h"
#include "midi_cue_automation_line.h"
#include "midi_cue_view.h" #include "midi_cue_view.h"
#include "midi_cue_velocity.h" #include "midi_cue_velocity.h"
#include "note.h" #include "note.h"
@ -46,6 +47,7 @@ MidiCueView::MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
MidiViewBackground& bg, MidiViewBackground& bg,
uint32_t basic_color) uint32_t basic_color)
: MidiView (mt, parent, ec, bg, basic_color) : MidiView (mt, parent, ec, bg, basic_color)
, automation_line (nullptr)
, velocity_base (nullptr) , velocity_base (nullptr)
, velocity_display (nullptr) , velocity_display (nullptr)
, _slot_index (slot_index) , _slot_index (slot_index)
@ -79,6 +81,9 @@ MidiCueView::MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
set_extensible (true); set_extensible (true);
set_region (region); set_region (region);
Evoral::Parameter fully_qualified_param (ARDOUR::MidiCCAutomation, 0, MIDI_CTL_MSB_MODWHEEL);
show_automation (fully_qualified_param);
} }
void void
@ -224,3 +229,63 @@ MidiCueView::update_hit (Hit* h)
velocity_display->update_note (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<AutomationControl> 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<Evoral::Control> control = _midi_region->model()->control (param, true);
std::shared_ptr<AutomationControl> ac = std::dynamic_pointer_cast<AutomationControl> (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;
}
}

View file

@ -28,6 +28,7 @@
#include "midi_view.h" #include "midi_view.h"
class VelocityDisplay; class VelocityDisplay;
class MidiCueAutomationLine;
class MidiCueView : public MidiView class MidiCueView : public MidiView
{ {
@ -52,12 +53,16 @@ class MidiCueView : public MidiView
void ghost_add_note (NoteBase*); void ghost_add_note (NoteBase*);
void ghost_sync_selection (NoteBase*); void ghost_sync_selection (NoteBase*);
void show_automation (Evoral::Parameter const & param);
ArdourCanvas::Item* drag_group() const; ArdourCanvas::Item* drag_group() const;
protected: protected:
bool scroll (GdkEventScroll* ev); bool scroll (GdkEventScroll* ev);
ArdourCanvas::Rectangle* automation_group; ArdourCanvas::Rectangle* automation_group;
MidiCueAutomationLine* automation_line;
ArdourCanvas::Rectangle* velocity_base; ArdourCanvas::Rectangle* velocity_base;
VelocityDisplay* velocity_display; VelocityDisplay* velocity_display;

View file

@ -160,6 +160,7 @@ gtk2_ardour_sources = [
'midi_automation_line.cc', 'midi_automation_line.cc',
'midi_channel_dialog.cc', 'midi_channel_dialog.cc',
'midi_channel_selector.cc', 'midi_channel_selector.cc',
'midi_cue_automation_line.cc',
'midi_cue_background.cc', 'midi_cue_background.cc',
'midi_cue_editor.cc', 'midi_cue_editor.cc',
'midi_cue_velocity.cc', 'midi_cue_velocity.cc',