MAKE_WHITE_BUTTON (Note, 50);
MAKE_WHITE_BUTTON (Session, 51);
MAKE_WHITE_BUTTON (Layout, 31);
- MAKE_WHITE_BUTTON (OctaveUp, 55);
+ MAKE_WHITE_BUTTON_PRESS (OctaveUp, 55, &Push2::button_octave_up);
MAKE_WHITE_BUTTON_PRESS (PageRight, 63, &Push2::button_page_right);
- MAKE_WHITE_BUTTON (OctaveDown, 54);
+ MAKE_WHITE_BUTTON_PRESS (OctaveDown, 54, &Push2::button_octave_down);
MAKE_WHITE_BUTTON_PRESS (PageLeft, 62, &Push2::button_page_left);
MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Shift, 49, &Push2::button_shift_press, &Push2::button_shift_release, &Push2::button_shift_long_press);
MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Select, 48, &Push2::button_select_press, &Push2::button_select_release, &Push2::button_select_long_press);
button.timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &Push2::button_long_press_timeout), id));
timeout->attach (main_loop()->get_context());
}
+
+void
+Push2::button_octave_down ()
+{
+ octave_shift = (max (-4, octave_shift - 1));
+ build_pad_table ();
+}
+
+void
+Push2::button_octave_up ()
+{
+ octave_shift = (max (4, octave_shift + 1));
+ build_pad_table ();
+}
build_pad_table ();
+ set_spacing (12);
+
pack_start (hpacker, false, false);
pack_start (pad_table, true, true);
for (int row = 0; row < 8; ++row) {
for (int col = 0; col < 8; ++col) {
l = manage (new Label);
- l->set_text (string_compose ("%1, %2", row, col));
+ l->set_text (string_compose ("%1", (int) p2.pad_note (row, col)));
l->show ();
- pad_table.attach (*l, col, col+1, 7 - row, 7 - row + 1);
+ pad_table.attach (*l, col, col+1, row, row + 1);
}
}
}
, bank_start (0)
, connection_state (ConnectionState (0))
, gui (0)
+ , octave_shift (0)
{
context = Cairo::Context::create (frame_buffer);
tc_clock_layout = Pango::Layout::create (context);
mid_layout[n]->set_font_description (fd3);
}
+ build_pad_table ();
build_maps ();
if (open ()) {
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,
+ Quantize, Duplicate, Browse, PageRight, PageLeft, OctaveUp, OctaveDown
};
for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) {
ButtonID off_buttons[] = { TapTempo, Setup, User, Stop, Convert, New, FixedLength,
Fwd32ndT, Fwd32nd, Fwd16thT, Fwd16th, Fwd8thT, Fwd8th, Fwd4trT, Fwd4tr,
- Accent, Scale, Layout, Note, Session, OctaveUp, OctaveDown, };
+ Accent, Scale, Layout, Note, Session, };
for (size_t n = 0; n < sizeof (off_buttons) / sizeof (off_buttons[0]); ++n) {
Button* b = id_button_map[off_buttons[n]];
pad->set_color (LED::Black);
pad->set_state (LED::OneShot24th);
write (pad->state_msg());
-
}
void
for (MidiBuffer::iterator ev = in.begin(); ev != in.end(); ++ev) {
if ((*ev).is_note_on() || (*ev).is_note_off()) {
/* encoder touch start/touch end use note 0-10 */
+
if ((*ev).note() > 10) {
+
+ /* shift for output to the shadow port */
+ (*ev).set_note ((*ev).note() + (octave_shift*12));
+
out.push_back (*ev);
+
+ /* shift back so that the pads light correctly */
+ (*ev).set_note ((*ev).note() - (octave_shift*12));
+
+
matched = true;
}
}
return _async_in;
}
+void
+Push2::build_pad_table ()
+{
+ for (int row = 0; row < 8; ++row ) {
+ for (int col = 0; col < 8; ++col) {
+ /* top left pad sends note number 92 by default */
+ int note_number = 92 - (row*8+col);
+ note_number += (octave_shift * 12);
+ note_number = max (0, min (127, note_number));
+ pad_table[row][col] = note_number;
+ }
+ }
+}
+
+uint8_t
+Push2::pad_note (int row, int col) const
+{
+ if (row < 8 && col < 8) {
+ return pad_table[row][col];
+ }
+
+ return 0;
+}