From 2afb7f1a309b3fc46f6f29dbfe8dc65da4b7d0e4 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 17 Jun 2016 09:21:29 -0400 Subject: [PATCH] basic implementation of scrubbing via push2 touch strip --- libs/surfaces/push2/push2.cc | 32 +++++++++++++++++++++++++++++++- libs/surfaces/push2/push2.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 5c1e54190a..ddefee3f56 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -465,6 +465,7 @@ Push2::set_active (bool yn) periodic_timeout->attach (main_loop()->get_context()); init_buttons (); + init_touch_strip (); switch_bank (0); } else { @@ -480,6 +481,20 @@ Push2::set_active (bool yn) return 0; } +void +Push2::init_touch_strip () +{ + MidiByteArray msg (9, 0xf0, 0x00, 0x21, 0x1d, 0x01, 0x01, 0x17, 0x00, 0xf7); + /* flags are the final byte (ignore end-of-sysex */ + + /* show bar, not point + autoreturn to center + bar starts at center + */ + msg[7] = (1<<4) | (1<<5) | (1<<6); + write (msg); +} + void Push2::write (const MidiByteArray& data) { @@ -648,6 +663,13 @@ Push2::handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes* ev) case 8: other_vpot_touch (3, ev->velocity > 64); break; + + /* touch strip */ + case 12: + if (ev->velocity < 64) { + transport_stop (); + } + break; } } @@ -660,7 +682,15 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev) void Push2::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb) { - cerr << "pitchbend @ " << pb << endl; + if (!session) { + return; + } + float speed; + + /* range of +1 .. -1 */ + speed = ((int32_t) pb - 8192) / 8192.0; + /* convert to range of +3 .. -3 */ + session->request_transport_speed (speed * 3.0); } void diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 6c5b38fd9f..62bebdd2ea 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -286,6 +286,7 @@ class Push2 : public ARDOUR::ControlProtocol IDButtonMap id_button_map; void init_buttons (); + void init_touch_strip (); /* map of Pads by note number */ typedef std::map NNPadMap;