noteTV

Monophonic MIDI keyboard note input. Only responding to a single note, with polyphonic aftertouch and gate output. When gate goes low, holds velocity of initial impact.
Author: Remco van der Most
License: BSD
Github: sss/midi/noteTV.axo

Inlets

None

Outlets

bool32 gate

frac32.positive polyphonic aftertouch

Parameters

int32 Note

Declaration
int8_t _note;
uint8_t _gate;
uint8_t _velo;
uint8_t _rvelo;
uint8_t _touch;
int Note;
Init
_gate = 0;
_note = 0;
_touch = 0;
Control Rate
outlet_gate = _gate << 27;
Note = param_Note;
if (_gate > 0) {
  outlet_touch = ___SMMUL(_touch << 23, _touch << 22);
}
if (_gate == 0) {
  outlet_touch = ___SMMUL(_velo << 23, _velo << 22);
}
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  if ((data1 >= Note) && (data1 <= Note)) {
    if (!(_gate)) {
      _touch = data2;
      _velo = data2;
    }
    _note = data1 - 64;
    _gate = 1;
  }
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
           (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if (_note == data1 - 64) {
    _gate = 0;
  }
} else if ((status == attr_midichannel + MIDI_POLY_PRESSURE) &&
           (data1 - 64 == _note)) {
  _touch = data2;
} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate = 0;
}

Privacy

© 2024 Zrna Research