table send vel

send data of a table as midi velocity messages.contents of a table will be scaled to range of 0-127. 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 vel.axo

Inlets

int32 offset

int32 startnote

int32 length

bool32.risingfalling active

bool32.rising redraw

Outlets

int32 offset

int32 startnote

int32 blocksize

Parameters

bool32.tgl active

int32 offset

int32 startnote

int32 length

Attributes

objref table

combo device

combo blocksize

spinner channel

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

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;
length = inlet_length + param_length;
start = inlet_startnote + param_startnote;

outlet_offset = offset;
outlet_startnote = start;
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) {
      MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON + (attr_channel - 1),
                start + i, (vt >> 20));
      prevt[i] = vt;
    }
  }
}

Privacy

© 2024 Zrna Research