seq midi feedback 16

visual feedback of table data for bidirectional midi-controllers (f.i. novation launchpad,livid base). 16 elements of a table are mapped to midi - notes.
Author: Robert Schirmer
License: BSD
Github: rbrt/old/seq midi feedback 16.axo

Inlets

int32 offset in the table

int32 current step

int32 velocity on modulation

frac32.bipolar delay time for step position display

Outlets

None

Parameters

int32 note velocity if step > 0

int32 note velocity if step <= 0

int32 velocity for current step

bool32.tgl display the current step

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

int32.mini map the step to midi notes

Attributes

objref table

combo device

spinner channel

Declaration
int ntrig;
int rtrig;
int prev;
int prevon;
int32_t val;

int32_t map[16];

int v;
int i;
int vt;
int trigt;
int prevt[16];
Init
{
  int i;
  for (i = 0; i < 16; i++)
    prevt[i] = -666;
}
Control Rate
map[0] = param_i0;
map[1] = param_i1;
map[2] = param_i2;
map[3] = param_i3;
map[4] = param_i4;
map[5] = param_i5;
map[6] = param_i6;
map[7] = param_i7;
map[8] = param_i8;
map[9] = param_i9;
map[10] = param_i10;
map[11] = param_i11;
map[12] = param_i12;
map[13] = param_i13;
map[14] = param_i14;
map[15] = param_i15;

// re-init

if (inlet_velon != prevon) {
  int i;
  for (i = 0; i < 16; i++)
    prevt[i] = -666;
  prevon = inlet_velon;
}

// display steps
{
  i += 1;
  if (i == 16)
    i = 0;
  vt = attr_table.array[__USAT((inlet_offset + i), 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),
              map[i], (param_on + inlet_velon));
    trigt = 1;
  }
  if ((!vt) && (!trigt)) {
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON + (attr_channel - 1),
              map[i], param_off);
    trigt = 1;
  }
}

// paint step index
if (param_clock) {
  v = attr_table
          .array[__USAT((inlet_offset + inlet_step), attr_table.LENGTHPOW)]
      << attr_table.GAIN;
  if ((inlet_step != prev) && !ntrig) {
    val = 1 << 30;
    ntrig = 1;
    MidiSend3((midi_device_t)attr_device, MIDI_NOTE_ON + (attr_channel - 1),
              map[inlet_step], param_step);
  } else {
    if (!(inlet_step != prev))
      ntrig = 0;
    if (val > 0) {
      int32_t t;
      MTOF(-((1 << 12) - inlet_delay), t);
      val -= t >> 3;
      if (val <= 0) {
        if (v)
          MidiSend3((midi_device_t)attr_device,
                    MIDI_NOTE_ON + (attr_channel - 1), map[inlet_step],
                    (param_on + inlet_velon));
        else
          MidiSend3((midi_device_t)attr_device,
                    MIDI_NOTE_ON + (attr_channel - 1), map[inlet_step],
                    param_off);
      }
    }
  }
  prev = inlet_step;
}

Privacy

© 2024 Zrna Research