table send note

send data of a table as midi note messages.if the data == 0,a note with velocity 'veloff' is sent,if the data > 0,velocity 'velon' is sent. set the start of the range of the notes to send with 'startnote',the length of the range with 'length'. useful for controllers capable of bi-directional midi,like 'livid base' or 'novation launchpad'.
Author: Robert Schirmer
License: BSD
Github: rbrt/midi/out/table send note.axo

Inlets

int32 offset

int32 startnote

int32 length

int32 velon

int32 veloff

bool32.risingfalling active

bool32.rising redraw

Outlets

int32 offset

int32 startnote

int32 velon

int32 veloff

int32 blocksize

Parameters

int32 offset

int32 startnote

int32 length

bool32.tgl active

Attributes

combo device

combo blocksize

spinner channel

spinner velon

spinner veloff

objref table

Declaration
int ntrig;
int v;
int i;
int vt;
int trigt;
int prevt[128];

uint8_t velon;
uint8_t veloff;
uint8_t start;
uint8_t length;
uint8_t plength;

uint32_t offset;
Init
{
  int i;
  for (i = 0; i < 128; i++)
    prevt[i] = -666;
}
Control Rate
offset = inlet_offset + param_offset;
velon = attr_velon + inlet_velon;
veloff = attr_veloff + inlet_veloff;
length = inlet_length + param_length;
start = inlet_startnote + param_startnote;

outlet_offset = offset;
outlet_startnote = start;
outlet_velon = velon;
outlet_veloff = veloff;
outlet_blocksize = attr_blocksize;

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

// re-init

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

// 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 + (attr_channel - 1),
                start + i, velon);
      trigt = 1;
    }
    if ((!vt) && (!trigt)) {
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON + (attr_channel - 1),
                start + i, veloff);
      trigt = 1;
    }
  }
}

Privacy

© 2024 Zrna Research