lppro: continuing adventures with shadow ports and pad maps
This commit is contained in:
parent
88a599816a
commit
7406ad01bd
@ -126,7 +126,7 @@ LaunchPadPro::probe (std::string& i, std::string& o)
|
||||
}
|
||||
|
||||
LaunchPadPro::LaunchPadPro (ARDOUR::Session& s)
|
||||
: MIDISurface (s, X_("Novation Launchpad Pro"), X_("Launchpad Pro"), false)
|
||||
: MIDISurface (s, X_("Novation Launchpad Pro"), X_("Launchpad Pro"), true)
|
||||
, _daw_out_port (nullptr)
|
||||
, _gui (nullptr)
|
||||
, _current_layout (SessionLayout)
|
||||
@ -143,7 +143,6 @@ LaunchPadPro::LaunchPadPro (ARDOUR::Session& s)
|
||||
connect_daw_ports ();
|
||||
|
||||
build_pad_map ();
|
||||
build_layout_maps ();
|
||||
}
|
||||
|
||||
LaunchPadPro::~LaunchPadPro ()
|
||||
@ -323,11 +322,6 @@ LaunchPadPro::output_daw_port_name () const
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
LaunchPadPro::stripable_selection_changed ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LaunchPadPro::build_pad_map ()
|
||||
{
|
||||
@ -385,7 +379,7 @@ LaunchPadPro::build_pad_map ()
|
||||
for (int row = 0; row < 8; ++row) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
int pid = (11 + (row * 10)) + col;
|
||||
std::pair<int,Pad> p (pid, Pad (pid, row, col));
|
||||
std::pair<int,Pad> p (pid, Pad (pid, col, row));
|
||||
if (!pad_map.insert (p).second) abort();
|
||||
}
|
||||
}
|
||||
@ -556,6 +550,16 @@ LaunchPadPro::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Launchpad, string_compose ("CC %1 (value %2)\n", (int) ev->controller_number, (int) ev->value));
|
||||
|
||||
if (_current_layout != SessionLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
PadMap::iterator p = pad_map.find (ev->controller_number);
|
||||
if (p == pad_map.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pad& pad (p->second);
|
||||
}
|
||||
|
||||
void
|
||||
@ -567,15 +571,34 @@ LaunchPadPro::handle_midi_note_on_message (MIDI::Parser& parser, MIDI::EventTwoB
|
||||
}
|
||||
|
||||
DEBUG_TRACE (DEBUG::Launchpad, string_compose ("Note On %1/0x%3%4%5 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity, std::hex, (int) ev->note_number, std::dec));
|
||||
std::pair<int,int> coord = note_to_xy (ev->note_number);
|
||||
std::cerr << "x: " << coord.first << " y: " << coord.second << std::endl;
|
||||
|
||||
if (_current_layout != SessionLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
PadMap::iterator p = pad_map.find (ev->note_number);
|
||||
if (p == pad_map.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pad& pad (p->second);
|
||||
}
|
||||
|
||||
void
|
||||
LaunchPadPro::handle_midi_note_off_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::Launchpad, string_compose ("Note Off %1 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity));
|
||||
DEBUG_TRACE (DEBUG::Launchpad, string_compose ("Note Off %1/0x%3%4%5 (velocity %2)\n", (int) ev->note_number, (int) ev->velocity, std::hex, (int) ev->note_number, std::dec));
|
||||
|
||||
if (_current_layout != SessionLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
PadMap::iterator p = pad_map.find (ev->note_number);
|
||||
if (p == pad_map.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pad& pad (p->second);
|
||||
}
|
||||
|
||||
void
|
||||
@ -696,142 +719,6 @@ LaunchPadPro::scroll_text (std::string const & txt, int color, bool loop, float
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LaunchPadPro::build_layout_maps ()
|
||||
{
|
||||
static const XY_Note_Map maps[] = {
|
||||
{ /* Session */
|
||||
{ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58 },
|
||||
{ 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e },
|
||||
{ 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44 },
|
||||
{ 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a },
|
||||
{ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30 },
|
||||
{ 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 },
|
||||
{ 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c },
|
||||
{ 0xb, 0xc, 0xe, 0xd, 0xf, 0x10, 0x11, 0x12 }
|
||||
},
|
||||
#if 0
|
||||
{ /* Fader */
|
||||
{ 0x0, 0x15, 0x2a, 0x3f, 0x40, 0x55, 0x6a, 0x7f },
|
||||
{ 0x0, 0x15, 0x2a, 0x3f, 0x40, 0x55, 0x6a, 0x7f },
|
||||
{ 0x0, 21, 42, 63, 64, 85, 106, 127 },
|
||||
{ 0x0, 21, 42, 63, 64, 85, 106, 127 },
|
||||
{ 0x0, 0x11, 0x22, 0x34, 0x46, 0x59, 0x6c, 0x7f },
|
||||
{ 0x0, 0x11, 0x22, 0x34, 0x46, 0x59, 0x6c, 0x7f },
|
||||
{ 0x0, 17, 34, 52, 70, 89, 108, 127 },
|
||||
{ 0x0, 17, 34, 52, 70, 89, 108, 127 }
|
||||
},
|
||||
{ /* Vertical Fader */
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,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x0, 0x0 }
|
||||
},
|
||||
{ /* CustomSettings */
|
||||
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }, { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
const size_t num_layouts = sizeof (maps) / sizeof (maps[0]);
|
||||
std::cerr << "We got " << num_layouts << " layouts\n";
|
||||
|
||||
layout_xy_note_map.resize (num_layouts * 64);
|
||||
|
||||
for (size_t layout = 0; layout < num_layouts; ++layout) {
|
||||
for (int row = 0; row < 8; ++row) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
layout_xy_note_map[xy_note_index (layout, col, row)] = maps[layout][row][col];
|
||||
// std::cerr << "IN col " << col << " row " << row << " note 0x" << std::hex << maps[layout][row][col] << std::dec << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layout_note_xy_map.resize (128 * num_layouts);
|
||||
|
||||
for (size_t layout = 0; layout < num_layouts; ++layout) {
|
||||
for (int row = 0; row < 8; ++row) {
|
||||
for (int col = 0; col < 8; ++col) {
|
||||
const int note = layout_xy_note_map[xy_note_index (layout, col, row)];
|
||||
std::cerr << "OUT layout " << layout << " col " << col << " row " << row << " note " << note << std::endl;
|
||||
layout_note_xy_map[note_xy_index(layout,note)] = row*8 + col;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
LaunchPadPro::note_xy_index (int layout, int note) const
|
||||
{
|
||||
return (layout * 127) + note;
|
||||
}
|
||||
|
||||
int
|
||||
LaunchPadPro::xy_note_index (int layout, int col, int row) const
|
||||
{
|
||||
return (layout * 64) + (row * 8) + col;
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
LaunchPadPro::note_to_xy (int note) const
|
||||
{
|
||||
int coord = layout_note_xy_map[note_xy_index ((int) _current_layout, note)];
|
||||
return std::pair<int,int> (coord % 8, coord / 8);
|
||||
}
|
||||
|
||||
LaunchPadPro::StripableSlot
|
||||
LaunchPadPro::get_stripable_slot (int x, int y) const
|
||||
{
|
||||
@ -848,3 +735,85 @@ LaunchPadPro::get_stripable_slot (int x, int y) const
|
||||
|
||||
return stripable_slots[x][y];
|
||||
}
|
||||
|
||||
void
|
||||
LaunchPadPro::stripable_selection_changed ()
|
||||
{
|
||||
std::shared_ptr<MidiPort> pad_port = std::dynamic_pointer_cast<AsyncMIDIPort>(_async_in)->shadow_port();
|
||||
std::shared_ptr<MidiTrack> current_midi_track = _current_pad_target.lock();
|
||||
std::shared_ptr<MidiTrack> new_pad_target;
|
||||
StripableNotificationList const & selected (last_selected());
|
||||
|
||||
/* See if there's a MIDI track selected */
|
||||
|
||||
for (StripableNotificationList::const_iterator si = selected.begin(); si != selected.end(); ++si) {
|
||||
|
||||
new_pad_target = std::dynamic_pointer_cast<MidiTrack> ((*si).lock());
|
||||
|
||||
if (new_pad_target) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (current_midi_track != new_pad_target) {
|
||||
|
||||
/* disconnect from pad port, if appropriate */
|
||||
|
||||
if (current_midi_track && pad_port) {
|
||||
|
||||
/* XXX this could possibly leave dangling MIDI notes.
|
||||
*
|
||||
* A general libardour fix is required. It isn't obvious
|
||||
* how note resolution can be done unless disconnecting
|
||||
* becomes "slow" (i.e. deferred for as long as it takes
|
||||
* to resolve notes).
|
||||
*/
|
||||
current_midi_track->input()->disconnect (current_midi_track->input()->nth(0), pad_port->name(), this);
|
||||
}
|
||||
|
||||
/* now connect the pad port to this (newly) selected midi
|
||||
* track, if indeed there is one.
|
||||
*/
|
||||
|
||||
if (new_pad_target && pad_port) {
|
||||
new_pad_target->input()->connect (new_pad_target->input()->nth (0), pad_port->name(), this);
|
||||
_current_pad_target = new_pad_target;
|
||||
// _selection_color = get_color_index (new_pad_target->presentation_info().color());
|
||||
// _contrast_color = get_color_index (Gtkmm2ext::HSV (new_pad_target->presentation_info().color()).opposite().color());
|
||||
} else {
|
||||
// _current_pad_target.reset ();
|
||||
// _selection_color = LED::Green;
|
||||
// _contrast_color = LED::Green;
|
||||
}
|
||||
|
||||
// reset_pad_colors ();
|
||||
}
|
||||
|
||||
// TrackMixLayout* tml = dynamic_cast<TrackMixLayout*> (_track_mix_layout);
|
||||
// assert (tml);
|
||||
|
||||
// tml->set_stripable (first_selected_stripable());
|
||||
}
|
||||
|
||||
bool
|
||||
LaunchPadPro::pad_filter (MidiBuffer& in, MidiBuffer& out) const
|
||||
{
|
||||
/* This filter is called asynchronously from a realtime process
|
||||
context. It must use atomics to check state, and must not block.
|
||||
*/
|
||||
|
||||
if (_current_layout != NoteLayout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool matched = false;
|
||||
|
||||
for (MidiBuffer::iterator ev = in.begin(); ev != in.end(); ++ev) {
|
||||
if ((*ev).is_note_on() || (*ev).is_note_off()) {
|
||||
out.push_back (*ev);
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
@ -232,9 +232,6 @@ class LaunchPadPro : public MIDISurface
|
||||
StripableSlotColumn stripable_slots;
|
||||
|
||||
StripableSlot get_stripable_slot (int x, int y) const;
|
||||
std::pair<int,int> note_to_xy (int note) const;
|
||||
int xy_note_index (int layout, int col, int row) const;
|
||||
int note_xy_index (int layout, int note) const;
|
||||
|
||||
typedef std::map<int,Pad> PadMap;
|
||||
PadMap pad_map;
|
||||
@ -249,6 +246,7 @@ class LaunchPadPro : public MIDISurface
|
||||
void stop_event_loop ();
|
||||
|
||||
void stripable_selection_changed ();
|
||||
std::weak_ptr<ARDOUR::MidiTrack> _current_pad_target;
|
||||
|
||||
void light_pad (int pad_id, int color, Pad::ColorMode);
|
||||
void pad_off (int pad_id);
|
||||
@ -286,14 +284,9 @@ class LaunchPadPro : public MIDISurface
|
||||
mutable LPPRO_GUI* _gui;
|
||||
void build_gui ();
|
||||
|
||||
typedef int XY_Note_Map[8][8];
|
||||
typedef int Note_XY_Map[127];
|
||||
|
||||
std::vector<int> layout_xy_note_map;
|
||||
std::vector<int> layout_note_xy_map;
|
||||
|
||||
void build_layout_maps ();
|
||||
Layout _current_layout;
|
||||
|
||||
bool pad_filter (ARDOUR::MidiBuffer& in, ARDOUR::MidiBuffer& out) const;
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
Loading…
Reference in New Issue
Block a user