summaryrefslogtreecommitdiff
path: root/libs/surfaces
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-09-22 10:27:21 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-09-27 14:59:31 -0500
commitcb340bf190f2835761392a581e22a6c6d5635928 (patch)
treebcaa800da2bdf9f479b0206c289b9e825c11bbf8 /libs/surfaces
parent0add64d4ab2609d8b0c0cab4b3500e3edf02bbe2 (diff)
push2: when playing pads, flash all pad LEDs for the same note number for the pressed pad
Diffstat (limited to 'libs/surfaces')
-rw-r--r--libs/surfaces/push2/push2.cc78
-rw-r--r--libs/surfaces/push2/push2.h9
2 files changed, 63 insertions, 24 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc
index 74e94511c9..b6ac5f5b02 100644
--- a/libs/surfaces/push2/push2.cc
+++ b/libs/surfaces/push2/push2.cc
@@ -793,24 +793,37 @@ Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* e
return;
}
- /* Pad */
+ /* Pad illuminations */
- NNPadMap::iterator pi = nn_pad_map.find (ev->note_number);
+ NNPadMap::const_iterator pm = nn_pad_map.find (ev->note_number);
- if (pi == nn_pad_map.end()) {
+ if (pm == nn_pad_map.end()) {
return;
}
- Pad* pad = pi->second;
+ const Pad * const pad_pressed = pm->second;
- if (pad->do_when_pressed == Pad::FlashOn) {
- pad->set_color (LED::White);
- pad->set_state (LED::OneShot24th);
- write (pad->state_msg());
- } else if (pad->do_when_pressed == Pad::FlashOff) {
- pad->set_color (LED::Black);
- pad->set_state (LED::OneShot24th);
- write (pad->state_msg());
+ pair<FNPadMap::iterator,FNPadMap::iterator> pads_with_note = fn_pad_map.equal_range (pad_pressed->filtered);
+
+ if (pads_with_note.first == fn_pad_map.end()) {
+ return;
+ }
+
+ for (FNPadMap::iterator pi = pads_with_note.first; pi != pads_with_note.second; ++pi) {
+ Pad* pad = pi->second;
+
+ if (pad->do_when_pressed == Pad::FlashOn) {
+ pad->set_color (LED::White);
+ pad->set_state (LED::OneShot24th);
+ write (pad->state_msg());
+ } else if (pad->do_when_pressed == Pad::FlashOff) {
+ /* XXX really need to pick a contrasting color from
+ selection color here.
+ */
+ pad->set_color (LED::Green);
+ pad->set_state (LED::OneShot24th);
+ write (pad->state_msg());
+ }
}
}
@@ -827,22 +840,34 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
return;
}
- NNPadMap::iterator pi = nn_pad_map.find (ev->note_number);
+ /* Pad illuminations */
- if (pi == nn_pad_map.end()) {
+ NNPadMap::const_iterator pm = nn_pad_map.find (ev->note_number);
+
+ if (pm == nn_pad_map.end()) {
return;
}
- Pad* pad = pi->second;
+ const Pad * const pad_pressed = pm->second;
+
+ pair<FNPadMap::iterator,FNPadMap::iterator> pads_with_note = fn_pad_map.equal_range (pad_pressed->filtered);
- if (pad->do_when_pressed == Pad::FlashOn) {
- pad->set_color (LED::Black);
- pad->set_state (LED::OneShot24th);
- write (pad->state_msg());
- } else if (pad->do_when_pressed == Pad::FlashOff) {
- pad->set_color (pad->perma_color);
- pad->set_state (LED::OneShot24th);
- write (pad->state_msg());
+ if (pads_with_note.first == fn_pad_map.end()) {
+ return;
+ }
+
+ for (FNPadMap::iterator pi = pads_with_note.first; pi != pads_with_note.second; ++pi) {
+ Pad* pad = pi->second;
+
+ if (pad->do_when_pressed == Pad::FlashOn) {
+ pad->set_color (LED::Black);
+ pad->set_state (LED::OneShot24th);
+ write (pad->state_msg());
+ } else if (pad->do_when_pressed == Pad::FlashOff) {
+ pad->set_color (pad->perma_color);
+ pad->set_state (LED::OneShot24th);
+ write (pad->state_msg());
+ }
}
}
@@ -1298,10 +1323,13 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey)
}
}
+ fn_pad_map.clear ();
+
if (inkey) {
vector<int>::iterator notei;
int row_offset = 0;
+
for (int row = 0; row < 8; ++row) {
/* Ableton's grid layout wraps the available notes in the scale
@@ -1321,6 +1349,8 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey)
notenum = *notei;
pad->filtered = notenum;
+ fn_pad_map.insert (make_pair (notenum, pad));
+
if ((notenum % 12) == original_root) {
pad->set_color (selection_color);
pad->perma_color = selection_color;
@@ -1358,6 +1388,8 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey)
pad->filtered = root_start + (note - 36);
+ fn_pad_map.insert (make_pair (pad->filtered, pad));
+
if (mode_map.find (note) != mode_map.end()) {
if ((note % 12) == original_root) {
diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h
index e102d83308..56229fc8ef 100644
--- a/libs/surfaces/push2/push2.h
+++ b/libs/surfaces/push2/push2.h
@@ -392,10 +392,17 @@ class Push2 : public ARDOUR::ControlProtocol
void init_buttons (bool startup);
void init_touch_strip ();
- /* map of Pads by note number */
+ /* map of Pads by note number (the "fixed" note number sent by the
+ * hardware, not the note number generated if the pad is touched)
+ */
typedef std::map<int,Pad*> NNPadMap;
NNPadMap nn_pad_map;
+ /* map of Pads by note number they generate (their "filtered" value)
+ */
+ typedef std::multimap<int,Pad*> FNPadMap;
+ FNPadMap fn_pad_map;
+
void set_button_color (ButtonID, uint8_t color_index);
void set_button_state (ButtonID, LED::State);
void set_led_color (ButtonID, uint8_t color_index);