matrix set holdmap

sends a note / a velocity when either changes
Author: robert schirmer
License: BSD
Github: rbrt/push/matrix set holdmap.axo

Inlets

int32.positive onClr

int32.positive offClr

int32.positive selClr

bool32.rising redraw

bool32.risingfalling select

bool32.risingfalling mute

int32 pad

Outlets

None

Attributes

spinner thin

objref holdmap

Declaration
uint8_t out[64];
uint8_t preout[64];
uint8_t counter;
uint8_t mcolor[4];
uint8_t mbrt;
bool trig;
uint8_t thin;

// calculate color and brightness
uint8_t getcolor(uint8_t color, uint8_t brightness) {
  uint8_t result;
  uint8_t bness;
  if (color > 1)
    bness = (2 - (brightness));
  else
    bness = brightness;
  result = color + bness;
  return result;
}
Control Rate
if (!inlet_mute) {
  if (inlet_redraw && !trig) {
    trig = 1;
    int i;
    for (i = 0; i < 64; i++)
      preout[i] = 128;
  }
  if (!inlet_redraw)
    trig = 0;

  if (attr_holdmap.array[counter])
    out[counter] = inlet_onClr;
  else
    out[counter] = inlet_offClr;

  // override the selected pad
  if (inlet_select)
    out[inlet_pad] = inlet_selClr;

  // send output map
  if (!thin) {
    if ((out[counter] != preout[counter]) &&
        !MidiGetOutputBufferPending(MIDI_DEVICE_USB_HOST)) {
      MidiSend3(MIDI_DEVICE_USB_HOST, 2, MIDI_NOTE_ON, counter + 36,
                out[counter]);
      thin = attr_thin;
      preout[counter] = out[counter];
    }
  } else
    thin--;

  counter++;
  counter = counter % 64;
}

Privacy

© 2024 Zrna Research