launchpad in

outputs the state of the buttons of a 'novation launchpad' (MKII or mini). will NOT work with the 'launchpad MK I' matrix: matrix-button index (from left-top to bottom-right) mgate: button pressed? right: right button index (top to bottom) rgate: pressed? top: top button index (left to right) tgate :pressed ?
Author: robert schirmer
License: BSD
Github: rbrt/launchpad/launchpad in.axo

Inlets

None

Outlets

int32 matrix

int32 right

int32 top

bool32 mgate

bool32 rgate

bool32 tgate

bool32.pulse mtrig

Declaration
int8_t _note1;
uint8_t _gate1;
int8_t _note2;
uint8_t _gate2;

uint8_t bitmask1 = 0b10001110;

int32_t _value;
int32_t _cc;
bool trig;
Control Rate
outlet_matrix = (_note1 - ((_note1 >> 4) << 3));
outlet_mgate = _gate1;
outlet_mtrig = trig;

outlet_right = (((_note2 - 8) >> 4) >= 0) ? ((_note2 - 8) >> 4) : 0;
outlet_rgate = _gate2;

outlet_top = (_cc >= 104) ? (_cc - 104) : 0;
outlet_tgate = _value;

trig = 0;
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  if ((data1 - 8) & bitmask1) {
    _note1 = data1;
    _gate1 = 1;
    trig = 1;
  }
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
           (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if (_note1 == data1) {
    _gate1 = 0;
  }

} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate1 = 0;
}

if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  if (!((data1 - 8) & bitmask1)) {
    _note2 = data1;
    _gate2 = 1;
  }
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
           (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if (_note2 == data1) {
    _gate2 = 0;
  }

} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate2 = 0;
}

if ((status & 0xF0) == MIDI_CONTROL_CHANGE) {
  _value = data2 << 20;
  ;
  _cc = data1;
}

Privacy

© 2024 Zrna Research