midi2cvRtrg

Monophonic MIDI keyboard note input, gate, retrigger, velocity and release velocity. Can select a different midichannel then main patch or follow patch midichannel.
Author: Remco van der Most
License: BSD
Github: sss/midi/midi2cvRtrg.axo

Inlets

None

Outlets

bool32 key pressed, no retrigger legato

bool32 key pressed, retrigger on legato

frac32.positive note-on velocity

frac32.positive note-off velocity

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

Attributes

combo mode

spinner channel

spinner highnote

spinner lownote

Declaration
int8_t _note;
bool _gate;
bool _trg;
uint8_t _velo;
uint8_t _rvelo;
int chn;
Init
_gate = 0;
_note = 0;
chn = attr_mode > 0 ? attr_channel - 1 : attr_midichannel;
Control Rate
outlet_note = _note << 21;
outlet_gate = _gate;
outlet_retrigger = _trg;
_trg = 0;

outlet_velocity = _velo << 20;
outlet_releaseVelocity = _rvelo << 20;
Midi Handler
if ((status == MIDI_NOTE_ON + chn) && (data2) && (data1 >= attr_lownote) &&
    (data1 <= attr_highnote)) {
  _velo = data2;
  _note = data1 - 64;
  _gate = 1 << 27;
  _trg = 1;
} else if (((status == MIDI_NOTE_ON + chn) && (!data2)) ||
           (status == MIDI_NOTE_OFF + chn)) {
  if (_note == data1 - 64) {
    _rvelo = data2;
    _gate = 0;
  }
} else if ((status == chn + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate = 0;
}

Privacy

© 2024 Zrna Research