slider 7

display and edit indexes of a table starting as horizontal sliders. 7 - step - version,the leftmost button sets the slider to 0. 'offset' = offset in the table to edit/display. 'rows' = how many elements to work on,starting from 'offset'. 'startrow' = row on the launchpad to start displaying on.
Author: robert schirmer
License: BSD
Github: rbrt/launchpad/slider 7.axo

Inlets

bool32.risingfalling active

bool32.rising redraw

int32.positive offset

int32.positive rows

int32.positive startrow

int32.positive color

Outlets

bool32.pulse pulse if sliders are changed

Parameters

int32 offset

int32 rows

int32 startrow

bool32.tgl active

Attributes

objref table

combo device

combo color

Declaration
int8_t _note1;
uint8_t _gate1;

int8_t pos;
int8_t prepos;

int32_t i;

int32_t v;
uint8_t vt;

int32_t prev[8];

uint32_t offset;
uint8_t onC;
uint8_t row;
uint8_t rows;
uint8_t prerow;

int32_t crow;

int ntrig;
int rtrig;
bool range;
Init
{
  int i;
  for (i = 0; i < 8; i++)
    prev[i] = -666;
}
Control Rate
offset = (param_offset + inlet_offset);
row = (param_startrow + inlet_startrow);
onC = (attr_color + inlet_color);
rows = (inlet_rows + param_rows);

if (inlet_active || param_active) {
  // redraw
  if ((inlet_redraw > 0) && !ntrig) {
    ntrig = 1;
    {
      int i;
      for (i = 0; i < rows; i++)
        prev[i] = -666;
    }
  }
  if (!(inlet_redraw > 0))
    ntrig = 0;

  {
    if ((crow == rows) || (rows != prerow)) {
      crow = 0;
      prerow = rows;
    }

    pos = (_note1 - ((row + crow) << 4));
    if (((pos >= 0) && (pos <= 7)) && ((pos != prepos) || _gate1)) {
      prepos = pos;
      attr_table.array[offset + crow] =
          __SSAT(((pos << 21) * 9), 28) >> attr_table.GAIN;
      range = 1;
    }

    v = ((attr_table.array[__USAT((offset + crow), attr_table.LENGTHPOW)]
          << attr_table.GAIN) >>
         24);

    // changed??
    if ((v != prev[crow]) && (range))
      rtrig = 1;

    if (v != prev[crow]) {
      i = 0;
      prev[crow] = v;
    }

    if (i < 8) {
      vt = (v > (i - 1)) ? (onC) : 0;
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON,
                (((row + crow) << 4) + i), vt);
      i += 1;
    } else
      crow += 1;
  }
  outlet_trig = rtrig;
  rtrig = 0;
}
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {

  _note1 = data1;
  _gate1 = 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;
}

Privacy

© 2024 Zrna Research