matrix disp

visual feedback of table data for the novation launchpad (NOT working with a LP mark I)
Author: Robert Schirmer
License: BSD
Github: rbrt/launchpad/matrix disp.axo

Inlets

bool32.rising redraw

int32 offset in the table to read from

int32 display start modulation

int32 display length modulation

int32 color on modulation

int32 color off modulation

bool32.risingfalling active??

Outlets

int32 offset through

int32 start through

int32 color on through

int32 color off through

int32 blocksize

Parameters

bool32.tgl active??

int32 length of the area to display

int32 display start on the LP

int32 offset

Attributes

objref name of the table to display

combo device

combo blocksize

combo coloron

combo coloroff

Declaration
int ntrig;
int rtrig;
uint8_t map[64];
int i;
int vt;
int trigt;
int prevt[64];
int length;
int plength;

uint8_t coloron;
uint8_t start;
uint8_t coloroff;
uint32_t offset;
Init
{
  int i;
  for (i = 0; i < 64; i++)
    prevt[i] = -666;
}

{
  int i;
  for (i = 0; i < 64; i++)

    map[i] = (((i >> 3) << 3) + i);
}
Control Rate
coloron = inlet_coloron + attr_coloron;
coloroff = inlet_coloroff + attr_coloroff;
offset = param_offset + inlet_offset;
start = inlet_start + param_start;
length = inlet_length + param_length;

// redraw
if ((inlet_redraw > 0) && !ntrig) {
  ntrig = 1;
  {
    int ii;
    for (ii = 0; ii < 64; ii++)
      prevt[ii] = -666;
  }
}
if (!(inlet_redraw > 0))
  ntrig = 0;

if (plength != length) {
  i = 0;
  plength = length;
}

// display steps
if (inlet_active || param_active) {
  {
    i += 1;
    if (i == (length))
      i = 0;
    vt = attr_table.array[__USAT((offset + (i << attr_blocksize)),
                                 attr_table.LENGTHPOW)]
         << attr_table.GAIN;
    if (prevt[i] != vt)
      trigt = 0;
    prevt[i] = vt;
    if (vt && (!trigt)) {
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON, map[(i + start)],
                (coloron));
      trigt = 1;
    }
    if ((!vt) && (!trigt)) {
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON, map[(i + start)],
                (coloroff));
      trigt = 1;
    }
  }
}

outlet_coloron = coloron;
outlet_coloroff = coloroff;
outlet_offset = offset;
outlet_start = start;
outlet_blocksize = attr_blocksize;

Privacy

© 2024 Zrna Research