From 8ed889543913042613316f16b57ec4f669e6c835 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 27 Aug 2022 08:15:40 -0600 Subject: [PATCH] push2: launch clips with pads --- libs/surfaces/push2/cues.cc | 7 +++++++ libs/surfaces/push2/cues.h | 2 ++ libs/surfaces/push2/layout.h | 3 +++ libs/surfaces/push2/push2.cc | 17 +++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/libs/surfaces/push2/cues.cc b/libs/surfaces/push2/cues.cc index 8d74de0df9..1c3889435b 100644 --- a/libs/surfaces/push2/cues.cc +++ b/libs/surfaces/push2/cues.cc @@ -47,6 +47,7 @@ #include "ardour/solo_isolate_control.h" #include "ardour/solo_safe_control.h" #include "ardour/tempo.h" +#include "ardour/triggerbox.h" #include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/rgb_macros.h" @@ -288,3 +289,9 @@ CueLayout::button_stop_press () _p2.get_session().stop_all_triggers (false); /* quantized global stop */ } } + +void +CueLayout::pad_press (int x, int y) +{ + _p2.bang (x + track_base, y + scene_base); +} diff --git a/libs/surfaces/push2/cues.h b/libs/surfaces/push2/cues.h index 76270a07e3..571e9b2492 100644 --- a/libs/surfaces/push2/cues.h +++ b/libs/surfaces/push2/cues.h @@ -67,6 +67,8 @@ class CueLayout : public Push2Layout void strip_vpot (int, int); void strip_vpot_touch (int, bool); + void pad_press (int x, int y); + private: ArdourCanvas::Rectangle* _bg; ArdourCanvas::Line* _upper_line; diff --git a/libs/surfaces/push2/layout.h b/libs/surfaces/push2/layout.h index 2632ce6e37..950d5e75d2 100644 --- a/libs/surfaces/push2/layout.h +++ b/libs/surfaces/push2/layout.h @@ -68,6 +68,9 @@ class Push2Layout : public sigc::trackable, public ArdourCanvas::Container virtual void strip_vpot (int, int) = 0; virtual void strip_vpot_touch (int, bool) = 0; + virtual void pad_press (int x, int y) {} + virtual void pad_release (int x, int y) {} + virtual void update_meters () {} virtual void update_clocks () {} diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 0c26420e9b..bfd165e65e 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -441,6 +441,10 @@ Push2::init_buttons (bool startup) } if (!startup) { + if (_current_layout) { + _current_layout->hide (); + } + for (NNPadMap::iterator pi = _nn_pad_map.begin(); pi != _nn_pad_map.end(); ++pi) { boost::shared_ptr pad = pi->second; @@ -806,6 +810,11 @@ Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* e boost::shared_ptr pad_pressed = pm->second; + if (_current_layout == _cue_layout) { + _current_layout->pad_press (pad_pressed->x, pad_pressed->y); + return; + } + pair pads_with_note = _fn_pad_map.equal_range (pad_pressed->filtered); if (pads_with_note.first == _fn_pad_map.end()) { @@ -844,6 +853,10 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev) boost::shared_ptr const pad_pressed = pm->second; + if (_current_layout == _cue_layout) { + _current_layout->pad_release (pad_pressed->x, pad_pressed->y); + return; + } pair pads_with_note = _fn_pad_map.equal_range (pad_pressed->filtered); if (pads_with_note.first == _fn_pad_map.end()) { @@ -1142,6 +1155,10 @@ Push2::pad_filter (MidiBuffer& in, MidiBuffer& out) const context. It must use atomics to check state, and must not block. */ + if (_current_layout == _cue_layout) { + return false; + } + bool matched = false; for (MidiBuffer::iterator ev = in.begin(); ev != in.end(); ++ev) {