keyb zone i

mod of 'keyb zone' by Johannes Thaelmann. Monophonic MIDI keyboard note input, gate, velocity and release velocity, only responding to a range of notes. integer note-nr output.
Author: Robert Schirmer
License: BSD
Github: rbrt/midi/in/keyb zone i.axo

Inlets

None

Outlets

bool32 key pressed?

frac32.positive note-on velocity

frac32.positive note-off velocity

int32 note number

Attributes

spinner startNote

spinner endNote

Declaration
int8_t _note;
uint8_t _gate;
uint8_t _velo;
uint8_t _rvelo;
uint8_t _touch;
Init
_gate = 0;
_note = 0;
_touch = 0;
Control Rate
outlet_note = _note;
outlet_gate = _gate << 27;
outlet_velocity = _velo << 20;
outlet_releaseVelocity = _rvelo << 20;
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  if ((data1 >= attr_startNote) && (data1 <= attr_endNote)) {
    _velo = data2;
    _note = data1;
    _gate = 1;
  }
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
           (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if (_note == data1) {
    _rvelo = data2;
    _gate = 0;
  }

} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  _gate = 0;
}

Privacy

© 2024 Zrna Research