bool32 Run
bool32.rising Reset
bool32 Song is playing
int32 Position in 4 counts per quarter
int32 Position in 24 counts per quarter
bool32.tgl secondary
frac32.u.map bpm
combo device
combo secondary
bool _active;
int32_t _posfrac;
int32_t _pos24ppq;
bool rstp;
_active = 0;
_posfrac = 0;
_pos24ppq = 0;
rstp = 0;
if (inlet_rst & !rstp) {
rstp = 1;
_posfrac = 0;
_pos24ppq = 0;
} else if (!inlet_rst) {
rstp = 0;
}
if (inlet_run && !_active) {
_active = 1;
if (_pos24ppq) {
MidiSend1((midi_device_t)attr_device, MIDI_CONTINUE);
if (param_secondary)
MidiSend1((midi_device_t)attr_secondary, MIDI_CONTINUE);
} else {
MidiSend1((midi_device_t)attr_device, MIDI_START);
if (param_secondary)
MidiSend1((midi_device_t)attr_secondary, MIDI_START);
}
} else if (!inlet_run && _active) {
_active = 0;
MidiSend1((midi_device_t)attr_device, MIDI_STOP);
if (param_secondary)
MidiSend1((midi_device_t)attr_secondary, MIDI_STOP);
}
if (_active) {
_posfrac += param_bpm;
if (_posfrac & 1 << 31) {
_posfrac &= (1 << 31) - 1;
_pos24ppq++;
MidiSend1((midi_device_t)attr_device, MIDI_TIMING_CLOCK);
if (param_secondary)
MidiSend1((midi_device_t)attr_secondary, MIDI_TIMING_CLOCK);
}
}
outlet_pos4ppq = _pos24ppq / 6;
outlet_pos24ppq = _pos24ppq;