push2: add an (x,y) map for pads and use it
This commit is contained in:
parent
a5dd6c1128
commit
6627d24c2b
@ -40,7 +40,8 @@ Push2::build_maps ()
|
|||||||
|
|
||||||
#define MAKE_PAD(x,y,nn) \
|
#define MAKE_PAD(x,y,nn) \
|
||||||
pad.reset (new Pad ((x), (y), (nn))); \
|
pad.reset (new Pad ((x), (y), (nn))); \
|
||||||
_nn_pad_map.insert (std::make_pair (pad->extra(), pad));
|
_nn_pad_map.insert (std::make_pair (pad->extra(), pad)); \
|
||||||
|
_xy_pad_map.insert (std::make_pair (y * 8 + x, pad));
|
||||||
|
|
||||||
MAKE_PAD (0, 0, 92);
|
MAKE_PAD (0, 0, 92);
|
||||||
MAKE_PAD (0, 1, 93);
|
MAKE_PAD (0, 1, 93);
|
||||||
|
@ -261,6 +261,7 @@ void
|
|||||||
CueLayout::button_lower (uint32_t n)
|
CueLayout::button_lower (uint32_t n)
|
||||||
{
|
{
|
||||||
if (_p2.stop_down()) {
|
if (_p2.stop_down()) {
|
||||||
|
std::cerr << "stop trigger in " << n + track_base << std::endl;
|
||||||
_p2.unbang (n + track_base);
|
_p2.unbang (n + track_base);
|
||||||
} else {
|
} else {
|
||||||
/* select track */
|
/* select track */
|
||||||
@ -440,26 +441,23 @@ CueLayout::update_labels ()
|
|||||||
/* total map size is only 64 so iterating over the whole thing is fine */
|
/* total map size is only 64 so iterating over the whole thing is fine */
|
||||||
|
|
||||||
for (int y = 0; y < 8; ++y) {
|
for (int y = 0; y < 8; ++y) {
|
||||||
for (auto & pad : _p2.nn_pad_map()) {
|
boost::shared_ptr<Push2::Pad> pad = _p2.pad_by_xy (n, y);
|
||||||
if (pad.second->y == n && pad.second->x == y) {
|
if (tb && tb->active()) {
|
||||||
if (tb && tb->active()) {
|
TriggerPtr tp = tb->trigger (y);
|
||||||
TriggerPtr tp = tb->trigger (y);
|
if (tp && tp->region()) {
|
||||||
if (tp && tp->region()) {
|
/* trigger in slot */
|
||||||
/* trigger in slot */
|
pad->set_color (color);
|
||||||
pad.second->set_color (color);
|
} else {
|
||||||
} else {
|
/* no trigger */
|
||||||
/* no trigger */
|
pad->set_color (Push2::LED::Black);
|
||||||
pad.second->set_color (Push2::LED::Black);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* no active triggerbox */
|
|
||||||
pad.second->set_color (Push2::LED::Black);
|
|
||||||
}
|
|
||||||
pad.second->set_state (Push2::LED::OneShot24th);
|
|
||||||
_p2.write (pad.second->state_msg());
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* no active triggerbox */
|
||||||
|
pad->set_color (Push2::LED::Black);
|
||||||
}
|
}
|
||||||
|
pad->set_state (Push2::LED::OneShot24th);
|
||||||
|
_p2.write (pad->state_msg());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -467,14 +465,10 @@ CueLayout::update_labels ()
|
|||||||
/* turn this column off */
|
/* turn this column off */
|
||||||
|
|
||||||
for (int y = 0; y < 8; ++y) {
|
for (int y = 0; y < 8; ++y) {
|
||||||
for (auto & pad : _p2.nn_pad_map()) {
|
boost::shared_ptr<Push2::Pad> pad = _p2.pad_by_xy (n, y);
|
||||||
if (pad.second->y == n && pad.second->x == y) {
|
pad->set_color (Push2::LED::Black);
|
||||||
pad.second->set_color (Push2::LED::Black);
|
pad->set_state (Push2::LED::OneShot24th);
|
||||||
pad.second->set_state (Push2::LED::OneShot24th);
|
_p2.write (pad->state_msg());
|
||||||
_p2.write (pad.second->state_msg());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -520,7 +514,8 @@ CueLayout::button_stop_press ()
|
|||||||
void
|
void
|
||||||
CueLayout::pad_press (int x, int y)
|
CueLayout::pad_press (int x, int y)
|
||||||
{
|
{
|
||||||
_p2.bang (x + track_base, y + scene_base);
|
std::cerr << "bang on " << x + track_base << ", " << y + scene_base << std::endl;
|
||||||
|
_p2.bang (y + scene_base, x + track_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -445,7 +445,7 @@ Push2::init_buttons (bool startup)
|
|||||||
_current_layout->hide ();
|
_current_layout->hide ();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NNPadMap::iterator pi = _nn_pad_map.begin(); pi != _nn_pad_map.end(); ++pi) {
|
for (PadMap::iterator pi = _nn_pad_map.begin(); pi != _nn_pad_map.end(); ++pi) {
|
||||||
boost::shared_ptr<Pad> pad = pi->second;
|
boost::shared_ptr<Pad> pad = pi->second;
|
||||||
|
|
||||||
pad->set_color (LED::Black);
|
pad->set_color (LED::Black);
|
||||||
@ -802,7 +802,7 @@ Push2::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoBytes* e
|
|||||||
|
|
||||||
/* Pad illuminations */
|
/* Pad illuminations */
|
||||||
|
|
||||||
NNPadMap::const_iterator pm = _nn_pad_map.find (ev->note_number);
|
PadMap::const_iterator pm = _nn_pad_map.find (ev->note_number);
|
||||||
|
|
||||||
if (pm == _nn_pad_map.end()) {
|
if (pm == _nn_pad_map.end()) {
|
||||||
return;
|
return;
|
||||||
@ -845,7 +845,7 @@ Push2::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
|
|||||||
|
|
||||||
/* Pad illuminations */
|
/* Pad illuminations */
|
||||||
|
|
||||||
NNPadMap::const_iterator pm = _nn_pad_map.find (ev->note_number);
|
PadMap::const_iterator pm = _nn_pad_map.find (ev->note_number);
|
||||||
|
|
||||||
if (pm == _nn_pad_map.end()) {
|
if (pm == _nn_pad_map.end()) {
|
||||||
return;
|
return;
|
||||||
@ -1171,7 +1171,7 @@ Push2::pad_filter (MidiBuffer& in, MidiBuffer& out) const
|
|||||||
if ((*ev).note() > 10 && (*ev).note() != 12) {
|
if ((*ev).note() > 10 && (*ev).note() != 12) {
|
||||||
|
|
||||||
const int n = (*ev).note ();
|
const int n = (*ev).note ();
|
||||||
NNPadMap::const_iterator nni = _nn_pad_map.find (n);
|
PadMap::const_iterator nni = _nn_pad_map.find (n);
|
||||||
|
|
||||||
if (nni != _nn_pad_map.end()) {
|
if (nni != _nn_pad_map.end()) {
|
||||||
boost::shared_ptr<const Pad> pad = nni->second;
|
boost::shared_ptr<const Pad> pad = nni->second;
|
||||||
@ -1314,7 +1314,7 @@ Push2::input_port()
|
|||||||
int
|
int
|
||||||
Push2::pad_note (int row, int col) const
|
Push2::pad_note (int row, int col) const
|
||||||
{
|
{
|
||||||
NNPadMap::const_iterator nni = _nn_pad_map.find (36+(row*8)+col);
|
PadMap::const_iterator nni = _nn_pad_map.find (36+(row*8)+col);
|
||||||
|
|
||||||
if (nni != _nn_pad_map.end()) {
|
if (nni != _nn_pad_map.end()) {
|
||||||
return nni->second->filtered;
|
return nni->second->filtered;
|
||||||
@ -1902,3 +1902,11 @@ Push2::set_pressure_mode (PressureMode pm)
|
|||||||
|
|
||||||
write (msg);
|
write (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<Push2::Pad>
|
||||||
|
Push2::pad_by_xy (int x, int y)
|
||||||
|
{
|
||||||
|
Push2::PadMap::iterator p = _xy_pad_map.find ((x * 8) +y);
|
||||||
|
assert (p != _xy_pad_map.end());
|
||||||
|
return p->second;
|
||||||
|
}
|
||||||
|
@ -453,8 +453,11 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
|
|
||||||
bool stop_down () const { return _stop_down; }
|
bool stop_down () const { return _stop_down; }
|
||||||
|
|
||||||
typedef std::map<int,boost::shared_ptr<Pad> > NNPadMap;
|
typedef std::map<int,boost::shared_ptr<Pad> > PadMap;
|
||||||
NNPadMap const & nn_pad_map() const { return _nn_pad_map; }
|
PadMap const & nn_pad_map() const { return _nn_pad_map; }
|
||||||
|
PadMap const & xy_pad_map() const { return _xy_pad_map; }
|
||||||
|
|
||||||
|
boost::shared_ptr<Pad> pad_by_xy (int x, int y);
|
||||||
|
|
||||||
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
|
CONTROL_PROTOCOL_THREADS_NEED_TEMPO_MAP_DECL();
|
||||||
|
|
||||||
@ -494,7 +497,11 @@ class Push2 : public ARDOUR::ControlProtocol
|
|||||||
/* map of Pads by note number (the "fixed" note number sent by the
|
/* map of Pads by note number (the "fixed" note number sent by the
|
||||||
* hardware, not the note number generated if the pad is touched)
|
* hardware, not the note number generated if the pad is touched)
|
||||||
*/
|
*/
|
||||||
NNPadMap _nn_pad_map;
|
PadMap _nn_pad_map;
|
||||||
|
|
||||||
|
/* map of Pads by x,y duple (computed as (x*8) + y */
|
||||||
|
|
||||||
|
PadMap _xy_pad_map;
|
||||||
|
|
||||||
/* map of Pads by note number they generate (their "filtered" value)
|
/* map of Pads by note number they generate (their "filtered" value)
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user