step disp

display a step counter on a novation launchpad
Author: Robert Schirmer
License: BSD
Github: rbrt/launchpad/step disp.axo

Inlets

int32 offset in the table to read from

int32 display start on the LP

int32 color on

int32 color off

int32 blocksize

int32 step color modulation

int32 current step

bool32 active??

bool32.rising redraw

Outlets

None

Parameters

bool32.tgl active

Attributes

objref table to display

combo device

combo color

Declaration
int ntrig;
int rtrig;
int prev;
int32_t map[64];
int32_t v;
Init
{
  int i;
  for (i = 0; i < 64; i++)

    map[i] = (((i >> 3) << 3) + i);
}
Control Rate
if (param_active || inlet_active) {
  rtrig = 0;

  if ((inlet_redraw > 0) && !ntrig) {
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
              map[inlet_step + inlet_start], (attr_color + inlet_color));
    ntrig = 1;
  }

  if (!(inlet_redraw > 0))
    ntrig = 0;

  if (inlet_step != prev) {
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
              map[(inlet_step + inlet_start)], (attr_color + inlet_color));

    v = attr_table.array[__USAT((inlet_offset + (prev << inlet_blocksize)),
                                attr_table.LENGTHPOW)]
        << attr_table.GAIN;
    if (v)
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
                map[(prev + inlet_start)], inlet_coloron);
    else
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
                map[(prev + inlet_start)], inlet_coloroff);
    prev = inlet_step;
  }

}

else if (!rtrig) {
  v = attr_table.array[__USAT((inlet_offset + (inlet_step << inlet_blocksize)),
                              attr_table.LENGTHPOW)]
      << attr_table.GAIN;
  if (v)
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
              map[(inlet_step + inlet_start)], inlet_coloron);
  else
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
              map[(inlet_step + inlet_start)], inlet_coloroff);
  rtrig = 1;
}

Privacy

© 2024 Zrna Research