clock

Midi clock slave
Author: Johannes Taelman
License: BSD
Github: midi/in/clock.axo

Inlets

None

Outlets

bool32 Song is playing

int32 Position in 4 counts per quarter

int32 Position in 24 counts per quarter

Declaration
int32_t _active;
int32_t _pos;
int32_t _pos_shadow;
Init
_active = 0;
_pos = 0;
_pos_shadow = 0;
Control Rate
outlet_active = _active;
outlet_pos4ppq = _pos / 6;
outlet_pos24ppq = _pos;
Midi Handler
if (status == MIDI_TIMING_CLOCK) {
  _pos_shadow++;
  _pos = _pos_shadow;
} else if (status == MIDI_START) {
  _active = 1;
  _pos = 0;
  _pos_shadow = -1;
} else if (status == MIDI_STOP) {
  _active = 0;
  _pos = -1;
} else if (status == MIDI_CONTINUE) {
  _active = 1;
} else if (status == MIDI_SONG_POSITION) {
  _pos_shadow = 6 * ((data2 << 7) + data1) - 1;
}

Privacy

© 2024 Zrna Research