13
0

launchpad pro: provide velocity info when launching clips/triggers

This commit is contained in:
Paul Davis 2023-09-08 14:41:06 -06:00
parent 36048ea651
commit b440488295
2 changed files with 31 additions and 19 deletions

View File

@ -810,7 +810,7 @@ LaunchPadPro::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoB
Pad& pad (p->second); Pad& pad (p->second);
maybe_start_press_timeout (pad); maybe_start_press_timeout (pad);
(this->*pad.on_press) (pad); (this->*pad.on_pad_press) (pad, ev->velocity);
} }
void void
@ -1531,9 +1531,9 @@ LaunchPadPro::lower8_press (Pad& pad)
} }
void void
LaunchPadPro::pad_press (Pad& pad) LaunchPadPro::pad_press (Pad& pad, int velocity)
{ {
DEBUG_TRACE (DEBUG::Launchpad, string_compose ("pad press on %1, %2 => %3\n", pad.x, pad.y, pad.id)); DEBUG_TRACE (DEBUG::Launchpad, string_compose ("pad press on %1, %2 => %3 vel %4\n", pad.x, pad.y, pad.id, velocity));
if (_clear_pressed) { if (_clear_pressed) {
TriggerPtr tp = session->trigger_at (pad.x, pad.y); TriggerPtr tp = session->trigger_at (pad.x, pad.y);
@ -1543,7 +1543,7 @@ LaunchPadPro::pad_press (Pad& pad)
return; return;
} }
session->bang_trigger_at (pad.x, pad.y); session->bang_trigger_at (pad.x, pad.y, velocity / 127.0f);
start_press_timeout (pad); start_press_timeout (pad);
} }

View File

@ -187,25 +187,28 @@ class LaunchPadPro : public MIDISurface
Pulsing = 0x2 Pulsing = 0x2
}; };
typedef void (LaunchPadPro::*PadMethod)(Pad&); typedef void (LaunchPadPro::*ButtonMethod)(Pad&);
typedef void (LaunchPadPro::*PadMethod)(Pad&, int velocity);
Pad (PadID pid, PadMethod press_method, PadMethod long_press_method = &LaunchPadPro::relax, PadMethod release_method = &LaunchPadPro::relax) Pad (PadID pid, ButtonMethod press_method, ButtonMethod long_press_method = &LaunchPadPro::relax, ButtonMethod release_method = &LaunchPadPro::relax)
: id (pid) : id (pid)
, x (-1) , x (-1)
, y (-1) , y (-1)
, on_press (press_method) {
, on_release (release_method) on_press = press_method;
, on_long_press (long_press_method) on_release = release_method;
{} on_long_press = long_press_method;
}
Pad (int pid, int xx, int yy, PadMethod press_method, PadMethod long_press_method = &LaunchPadPro::relax, PadMethod release_method = &LaunchPadPro::relax) Pad (int pid, int xx, int yy, PadMethod press_method, ButtonMethod long_press_method = &LaunchPadPro::relax, ButtonMethod release_method = &LaunchPadPro::relax)
: id (pid) : id (pid)
, x (xx) , x (xx)
, y (yy) , y (yy)
, on_press (press_method) {
, on_release (release_method) on_pad_press = press_method;
, on_long_press (long_press_method) on_release = release_method;
{} on_long_press = long_press_method;
}
MIDI::byte status_byte() const { if (x < 0) return 0xb0; return 0x90; } MIDI::byte status_byte() const { if (x < 0) return 0xb0; return 0x90; }
bool is_pad () const { return x >= 0; } bool is_pad () const { return x >= 0; }
@ -214,9 +217,18 @@ class LaunchPadPro : public MIDISurface
int id; int id;
int x; int x;
int y; int y;
PadMethod on_press;
PadMethod on_release; /* It's either a button (CC number) or a pad (note number
PadMethod on_long_press; * w/velocity info), never both.
*/
union {
ButtonMethod on_press;
PadMethod on_pad_press;
};
ButtonMethod on_release;
ButtonMethod on_long_press;
sigc::connection timeout_connection; sigc::connection timeout_connection;
}; };
@ -438,7 +450,7 @@ class LaunchPadPro : public MIDISurface
void fader_long_press (Pad&); void fader_long_press (Pad&);
void fader_release (Pad&); void fader_release (Pad&);
void pad_press (Pad&); void pad_press (Pad&, int velocity);
void pad_long_press (Pad&); void pad_long_press (Pad&);
void trigger_property_change (PBD::PropertyChange, ARDOUR::Trigger*); void trigger_property_change (PBD::PropertyChange, ARDOUR::Trigger*);