note on

noteOn issues a pulse whenever a note-on occurs, note returns the note number. hold is 1 if any keys are on hold.
Author: Robert Schirmer
License: BSD
Github: rbrt/midi/in/note on.axo

Inlets

None

Outlets

int32 note on note-on

bool32.pulse pulse on note-on

bool32 any notes on hold?

Attributes

spinner startNote

spinner endNote

Declaration
int8_t _note;
uint8_t count;
bool trigon;
Init
_note = 0;
Control Rate
outlet_noteOn = trigon;
outlet_note = _note;
trigon = 0;

outlet_gate = bool(count);
Midi Handler
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
  if ((data1 >= attr_startNote) && (data1 <= attr_endNote)) {
    trigon = 1;
    count += 1;
    _note = data1;
  }
}
if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
    (status == MIDI_NOTE_OFF + attr_midichannel)) {
  if ((data1 >= attr_startNote) && (data1 <= attr_endNote)) {
    if (count)
      count -= 1;
  }
} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
           (data1 == MIDI_C_ALL_NOTES_OFF)) {
  count = 0;
}

Privacy

© 2024 Zrna Research