diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-07-09 23:26:02 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:30 -0500 |
commit | b37531e04f1f8786ffcc8599759aa93411d42c1b (patch) | |
tree | eb6453025b8f829ea1fdf336cdcc8f39438eafa1 | |
parent | 5e407406c419ae578da2821e619b55a8093ac54b (diff) |
push2: basics of 4x 4x4 percussive mode, similar to MPC (and vaguely to Live)
-rw-r--r-- | libs/surfaces/push2/buttons.cc | 2 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.cc | 56 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.h | 4 |
3 files changed, 59 insertions, 3 deletions
diff --git a/libs/surfaces/push2/buttons.cc b/libs/surfaces/push2/buttons.cc index 3b519babbf..6925517f68 100644 --- a/libs/surfaces/push2/buttons.cc +++ b/libs/surfaces/push2/buttons.cc @@ -194,7 +194,7 @@ Push2::build_maps () MAKE_WHITE_BUTTON_PRESS (Repeat, 56, &Push2::button_repeat); MAKE_WHITE_BUTTON (Accent, 57); MAKE_WHITE_BUTTON (Scale, 58); - MAKE_WHITE_BUTTON (Layout, 31); + MAKE_WHITE_BUTTON_PRESS (Layout, 31, &Push2::button_layout_press); MAKE_WHITE_BUTTON (Note, 50); MAKE_WHITE_BUTTON (Session, 51); MAKE_WHITE_BUTTON (Layout, 31); diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 3f326940c0..d4fe17bbd0 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -131,6 +131,7 @@ Push2::Push2 (ARDOUR::Session& s) , _root_octave (3) , _in_key (true) , octave_shift (0) + , percussion (false) { context = Cairo::Context::create (frame_buffer); tc_clock_layout = Pango::Layout::create (context); @@ -339,7 +340,7 @@ Push2::init_buttons (bool startup) ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo, Metronome, Shift, Select, Play, RecordEnable, Automate, Repeat, Note, Session, DoubleLoop, - Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown + Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown, Layout }; for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) { @@ -375,7 +376,7 @@ Push2::init_buttons (bool startup) ButtonID off_buttons[] = { TapTempo, Setup, User, Stop, Convert, New, FixedLength, Fwd32ndT, Fwd32nd, Fwd16thT, Fwd16th, Fwd8thT, Fwd8th, Fwd4trT, Fwd4tr, - Accent, Scale, Layout, Note, Session, }; + Accent, Scale, Note, Session, }; for (size_t n = 0; n < sizeof (off_buttons) / sizeof (off_buttons[0]); ++n) { Button* b = id_button_map[off_buttons[n]]; @@ -1933,3 +1934,54 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey) _in_key = inkey; _mode = mode; } + +void +Push2::set_percussive_mode (bool yn) +{ + if (!yn) { + cerr << "back to scale\n"; + set_pad_scale (_scale_root, _root_octave, _mode, _in_key); + percussion = false; + return; + } + + int drum_note = 36; + + for (int row = 0; row < 8; ++row) { + + for (int col = 0; col < 4; ++col) { + + int index = 36 + (row*8) + col; + Pad* pad = nn_pad_map[index]; + + pad->filtered = drum_note; + drum_note++; + } + } + + for (int row = 0; row < 8; ++row) { + + for (int col = 4; col < 8; ++col) { + + int index = 36 + (row*8) + col; + Pad* pad = nn_pad_map[index]; + + pad->filtered = drum_note; + drum_note++; + } + } + + percussion = true; + + PadChange (); /* EMIT SIGNAL */ +} + +void +Push2::button_layout_press () +{ + if (percussion) { + set_percussive_mode (false); + } else { + set_percussive_mode (true); + } +} diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 6180d66813..d1655d1d60 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -459,6 +459,7 @@ class Push2 : public ARDOUR::ControlProtocol void button_page_right (); void button_octave_up (); void button_octave_down (); + void button_layout_press (); void start_shift (); void end_shift (); @@ -532,6 +533,9 @@ class Push2 : public ARDOUR::ControlProtocol bool _in_key; int octave_shift; + + bool percussion; + void set_percussive_mode (bool); }; |