arpMidi

Monophonic MIDI keyboard note input, gate, velocity and release velocity. Polyphonic touch output.
Author: Johannes Taelman
License: BSD
Github: sss/midi/arpMidi.axo

Inlets

bool32 gate

Outlets

bool32 key pressed, no retrigger legato

frac32.bipolar midi note number (-64..63)

frac32.positive note-on velocity

Parameters

int32 length

bool32.tgl sustain

bin16 S

Declaration
int8_t _note;
int32_t _gate;
uint8_t _velo;
uint8_t _poly;
int32_t temp;
int gate[8];
int note[8];
int velo[8];
int i;
int pos[8];
int32_t N[8];
int32_t V[8];
int32_t notE;
int32_t velO;
uint32_t cnt;
int gtrig;
int ttrig;
int sustain;
Init
for (i = 0; i < 8; i++) {
  gate[i] = 0;
  note[i] = 0;
  velo[i] = 0;
}
Control Rate
if ((inlet_gate > 0) && !gtrig) {
  gtrig = 1;
  cnt = cnt + 1;
  cnt = cnt - (cnt / param_length) * param_length;
} else if (inlet_gate <= 0) {
  gtrig = 0;
}

if ((_gate > 0) && !ttrig) {
  ttrig = 1;
  cnt = 0;
} else if (gate == 0) {
  ttrig = 0;
}

if (_gate > 0) {
  outlet_gate = ((param_S >> (cnt & 15)) & 1) && inlet_gate;
  notE = _note - 64;
  velO = _velo;
} else {
  outlet_gate = 0;
}
outlet_note = notE << 21;
outlet_velocity = velO << 20;
sustain = param_sustain;
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  _velo = data2;
  _note = data1;
  _gate = 1;
  _poly = parent->polyIndex;
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
           (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if ((_note == data1) && (sustain == 0)) {
    _gate = 0;
  }
} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate = 0;
}

Privacy

© 2024 Zrna Research