push2: basics of octave shifting
This commit is contained in:
parent
915f937aa4
commit
eff67c8a8f
@ -197,9 +197,9 @@ Push2::build_maps ()
|
|||||||
MAKE_WHITE_BUTTON (Note, 50);
|
MAKE_WHITE_BUTTON (Note, 50);
|
||||||
MAKE_WHITE_BUTTON (Session, 51);
|
MAKE_WHITE_BUTTON (Session, 51);
|
||||||
MAKE_WHITE_BUTTON (Layout, 31);
|
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_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 (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 (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);
|
MAKE_WHITE_BUTTON_PRESS_RELEASE_LONG (Select, 48, &Push2::button_select_press, &Push2::button_select_release, &Push2::button_select_long_press);
|
||||||
@ -589,3 +589,17 @@ Push2::start_press_timeout (Button& button, ButtonID id)
|
|||||||
button.timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &Push2::button_long_press_timeout), id));
|
button.timeout_connection = timeout->connect (sigc::bind (sigc::mem_fun (*this, &Push2::button_long_press_timeout), id));
|
||||||
timeout->attach (main_loop()->get_context());
|
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 ();
|
||||||
|
}
|
||||||
|
@ -127,6 +127,8 @@ P2GUI::P2GUI (Push2& p)
|
|||||||
|
|
||||||
build_pad_table ();
|
build_pad_table ();
|
||||||
|
|
||||||
|
set_spacing (12);
|
||||||
|
|
||||||
pack_start (hpacker, false, false);
|
pack_start (hpacker, false, false);
|
||||||
pack_start (pad_table, true, true);
|
pack_start (pad_table, true, true);
|
||||||
|
|
||||||
@ -410,9 +412,9 @@ P2GUI::build_pad_table ()
|
|||||||
for (int row = 0; row < 8; ++row) {
|
for (int row = 0; row < 8; ++row) {
|
||||||
for (int col = 0; col < 8; ++col) {
|
for (int col = 0; col < 8; ++col) {
|
||||||
l = manage (new Label);
|
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 ();
|
l->show ();
|
||||||
pad_table.attach (*l, col, col+1, 7 - row, 7 - row + 1);
|
pad_table.attach (*l, col, col+1, row, row + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ Push2::Push2 (ARDOUR::Session& s)
|
|||||||
, bank_start (0)
|
, bank_start (0)
|
||||||
, connection_state (ConnectionState (0))
|
, connection_state (ConnectionState (0))
|
||||||
, gui (0)
|
, gui (0)
|
||||||
|
, octave_shift (0)
|
||||||
{
|
{
|
||||||
context = Cairo::Context::create (frame_buffer);
|
context = Cairo::Context::create (frame_buffer);
|
||||||
tc_clock_layout = Pango::Layout::create (context);
|
tc_clock_layout = Pango::Layout::create (context);
|
||||||
@ -96,6 +97,7 @@ Push2::Push2 (ARDOUR::Session& s)
|
|||||||
mid_layout[n]->set_font_description (fd3);
|
mid_layout[n]->set_font_description (fd3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_pad_table ();
|
||||||
build_maps ();
|
build_maps ();
|
||||||
|
|
||||||
if (open ()) {
|
if (open ()) {
|
||||||
@ -240,7 +242,7 @@ Push2::init_buttons (bool startup)
|
|||||||
|
|
||||||
ButtonID buttons[] = { Mute, Solo, Master, Up, Right, Left, Down, Note, Session, Mix, AddTrack, Delete, Undo,
|
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,
|
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) {
|
for (size_t n = 0; n < sizeof (buttons) / sizeof (buttons[0]); ++n) {
|
||||||
@ -276,7 +278,7 @@ Push2::init_buttons (bool startup)
|
|||||||
|
|
||||||
ButtonID off_buttons[] = { TapTempo, Setup, User, Stop, Convert, New, FixedLength,
|
ButtonID off_buttons[] = { TapTempo, Setup, User, Stop, Convert, New, FixedLength,
|
||||||
Fwd32ndT, Fwd32nd, Fwd16thT, Fwd16th, Fwd8thT, Fwd8th, Fwd4trT, Fwd4tr,
|
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) {
|
for (size_t n = 0; n < sizeof (off_buttons) / sizeof (off_buttons[0]); ++n) {
|
||||||
Button* b = id_button_map[off_buttons[n]];
|
Button* b = id_button_map[off_buttons[n]];
|
||||||
@ -872,7 +874,6 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
|
|||||||
pad->set_color (LED::Black);
|
pad->set_color (LED::Black);
|
||||||
pad->set_state (LED::OneShot24th);
|
pad->set_state (LED::OneShot24th);
|
||||||
write (pad->state_msg());
|
write (pad->state_msg());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1507,8 +1508,18 @@ Push2::pad_filter (MidiBuffer& in, MidiBuffer& out) const
|
|||||||
for (MidiBuffer::iterator ev = in.begin(); ev != in.end(); ++ev) {
|
for (MidiBuffer::iterator ev = in.begin(); ev != in.end(); ++ev) {
|
||||||
if ((*ev).is_note_on() || (*ev).is_note_off()) {
|
if ((*ev).is_note_on() || (*ev).is_note_off()) {
|
||||||
/* encoder touch start/touch end use note 0-10 */
|
/* encoder touch start/touch end use note 0-10 */
|
||||||
|
|
||||||
if ((*ev).note() > 10) {
|
if ((*ev).note() > 10) {
|
||||||
|
|
||||||
|
/* shift for output to the shadow port */
|
||||||
|
(*ev).set_note ((*ev).note() + (octave_shift*12));
|
||||||
|
|
||||||
out.push_back (*ev);
|
out.push_back (*ev);
|
||||||
|
|
||||||
|
/* shift back so that the pads light correctly */
|
||||||
|
(*ev).set_note ((*ev).note() - (octave_shift*12));
|
||||||
|
|
||||||
|
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1580,3 +1591,26 @@ Push2::input_port()
|
|||||||
return _async_in;
|
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;
|
||||||
|
}
|
||||||
|
@ -87,6 +87,8 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
boost::shared_ptr<ARDOUR::Port> input_port();
|
boost::shared_ptr<ARDOUR::Port> input_port();
|
||||||
boost::shared_ptr<ARDOUR::Port> output_port();
|
boost::shared_ptr<ARDOUR::Port> output_port();
|
||||||
|
|
||||||
|
uint8_t pad_note (int row, int col) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
libusb_device_handle *handle;
|
libusb_device_handle *handle;
|
||||||
uint8_t frame_header[16];
|
uint8_t frame_header[16];
|
||||||
@ -419,6 +421,8 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
void button_select_long_press ();
|
void button_select_long_press ();
|
||||||
void button_page_left ();
|
void button_page_left ();
|
||||||
void button_page_right ();
|
void button_page_right ();
|
||||||
|
void button_octave_up ();
|
||||||
|
void button_octave_down ();
|
||||||
|
|
||||||
void start_shift ();
|
void start_shift ();
|
||||||
void end_shift ();
|
void end_shift ();
|
||||||
@ -479,6 +483,11 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
mutable void *gui;
|
mutable void *gui;
|
||||||
void build_gui ();
|
void build_gui ();
|
||||||
|
|
||||||
|
/* pad mapping */
|
||||||
|
|
||||||
|
uint8_t pad_table[8][8];
|
||||||
|
void build_pad_table();
|
||||||
|
int octave_shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user