push2: basics of 4x 4x4 percussive mode, similar to MPC (and vaguely to Live)

This commit is contained in:
Paul Davis 2016-07-09 23:26:02 -04:00
parent 5e407406c4
commit b37531e04f
3 changed files with 59 additions and 3 deletions

View 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);

View 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);
}
}

View 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);
};