bool32.rising starts/stops internal clock
bool32.rising Reset
frac32.positive speed and that, yeah bruv?
bool32 Song is playing
bool32 external
bool32 internal
bool32.tgl onA
bool32.tgl onB
bool32.tgl onC
bool32.tgl onD
combo Aoutput
combo Boutput
combo Coutput
combo Doutput
bool internal;
int32_t _posfrac;
int32_t _pos24ppq;
bool rstp;
int external;
int rtrig;
int run;
int paramon;
int paramonB;
int paramonC;
int paramonD;
internal = 0;
_posfrac = 0;
_pos24ppq = 0;
rstp = 0;
run = 0;
paramon = param_onA;
paramonB = param_onB;
paramonC = param_onC;
paramonD = param_onD;
if (inlet_rst & !rstp) {
rstp = 1;
_posfrac = 0;
_pos24ppq = 0;
} else if (!inlet_rst) {
rstp = 0;
}
if (!external) {
if (inlet_run && !rtrig) {
rtrig = 1;
run = !run;
} else if (!inlet_run) {
rtrig = 0;
}
if (run && !internal) {
internal = 1;
if (_pos24ppq) {
PatchMidiInHandler(MIDI_DEVICE_INTERNAL, 0, MIDI_START, 0, 0);
} else {
PatchMidiInHandler(MIDI_DEVICE_INTERNAL, 0, MIDI_CONTINUE, 0, 0);
}
} else if (!run && internal) {
internal = 0;
PatchMidiInHandler(MIDI_DEVICE_INTERNAL, 0, MIDI_STOP, 0, 0);
}
if (internal) {
_posfrac += inlet_bpm;
if (_posfrac & 1 << 31) {
_posfrac &= (1 << 31) - 1;
_pos24ppq++;
PatchMidiInHandler(MIDI_DEVICE_INTERNAL, 0, MIDI_TIMING_CLOCK, 0, 0);
}
}
}
outlet_external = external;
outlet_internal = internal;
outlet_active = external || internal;
if ((dev == MIDI_DEVICE_INTERNAL) && (status == MIDI_START)) {
external = 0;
}
if ((dev != MIDI_DEVICE_INTERNAL) && (status == MIDI_START)) {
external = 1;
internal = 0;
run = 0;
}
if ((dev != MIDI_DEVICE_INTERNAL) && (status == MIDI_STOP)) {
external = 0;
}
if ((status == MIDI_TIMING_CLOCK) || (status == MIDI_START) ||
(status == MIDI_CONTINUE) || (status == MIDI_STOP)) {
if (paramon) {
MidiSend1((midi_device_t)attr_Aoutput, status);
}
if (paramonB) {
MidiSend1((midi_device_t)attr_Boutput, status);
}
if (paramonC) {
MidiSend1((midi_device_t)attr_Coutput, status);
}
if (paramonD) {
MidiSend1((midi_device_t)attr_Doutput, status);
}
}