push2: basics of 4x 4x4 percussive mode, similar to MPC (and vaguely to Live)
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 10 Jul 2016 03:26:02 +0000 (23:26 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:30 +0000 (14:59 -0500)
libs/surfaces/push2/buttons.cc
libs/surfaces/push2/push2.cc
libs/surfaces/push2/push2.h

index 3b519babbf332a80e8356218f95cc203f8ceccab..6925517f68247bd3e4006c55eabf23d2403b2a49 100644 (file)
@@ -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);
index 3f326940c04e40e5a01bc4ca97fb15bc86d0620d..d4fe17bbd07aa277a8c8ce1f521a394073305765 100644 (file)
@@ -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);
+       }
+}
index 6180d66813d1e6ff6bb2b413ba6611f980c4dd89..d1655d1d609f4024e03865201e43461f4167b3cd 100644 (file)
@@ -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);
 };