mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-18 12:46:32 +01:00
push2: use a map for direct lookup of pad note
This commit is contained in:
parent
66453868cd
commit
afef816a7b
2 changed files with 18 additions and 19 deletions
|
|
@ -1512,14 +1512,19 @@ Push2::pad_filter (MidiBuffer& in, MidiBuffer& out) const
|
||||||
|
|
||||||
if ((*ev).note() > 10) {
|
if ((*ev).note() > 10) {
|
||||||
|
|
||||||
|
int n = (*ev).note ();
|
||||||
|
|
||||||
|
map<int,int>::const_iterator ni = pad_map.find (n);
|
||||||
|
|
||||||
|
if (ni != pad_map.end()) {
|
||||||
/* shift for output to the shadow port */
|
/* shift for output to the shadow port */
|
||||||
(*ev).set_note ((*ev).note() + (octave_shift*12));
|
(*ev).set_note (ni->second);
|
||||||
|
|
||||||
out.push_back (*ev);
|
out.push_back (*ev);
|
||||||
|
|
||||||
/* shift back so that the pads light correctly */
|
/* shift back so that the pads light correctly */
|
||||||
(*ev).set_note ((*ev).note() - (octave_shift*12));
|
(*ev).set_note (n);
|
||||||
|
} else {
|
||||||
|
out.push_back (*ev);
|
||||||
|
}
|
||||||
|
|
||||||
matched = true;
|
matched = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1595,16 +1600,8 @@ Push2::input_port()
|
||||||
void
|
void
|
||||||
Push2::build_pad_table ()
|
Push2::build_pad_table ()
|
||||||
{
|
{
|
||||||
for (int row = 0; row < 8; ++row ) {
|
for (int i = 36; i < 99; ++i) {
|
||||||
for (int col = 0; col < 8; ++col) {
|
pad_map[i] = i + (octave_shift*12);
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PadChange (); /* emit signal */
|
PadChange (); /* emit signal */
|
||||||
|
|
@ -1613,8 +1610,10 @@ Push2::build_pad_table ()
|
||||||
uint8_t
|
uint8_t
|
||||||
Push2::pad_note (int row, int col) const
|
Push2::pad_note (int row, int col) const
|
||||||
{
|
{
|
||||||
if (row < 8 && col < 8) {
|
map<int,int>::const_iterator ni = pad_map.find (row*8+col);
|
||||||
return pad_table[row][col];
|
|
||||||
|
if (ni != pad_map.end()) {
|
||||||
|
return ni->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -488,7 +488,7 @@ class Push2 : public ARDOUR::ControlProtocol
|
||||||
|
|
||||||
/* pad mapping */
|
/* pad mapping */
|
||||||
|
|
||||||
uint8_t pad_table[8][8];
|
std::map<int,int> pad_map;
|
||||||
void build_pad_table();
|
void build_pad_table();
|
||||||
int octave_shift;
|
int octave_shift;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue