int32.positive position
bool32.risingfalling start
bool32.risingfalling stop
bool32.risingfalling continue
bool32.risingfalling clock
bool32.risingfalling reset
bool32.risingfalling random
bool32.risingfalling trg1
bool32.risingfalling trg2
bool32.risingfalling trg3
int32 position
bool32 active
bool32 clock
bool32 reset
bool32 random
spinner CH
spinner CC
combo device
int pos, trg, act, ACT, stop, rnd, rst;
int AS = inlet_start || inlet_continue;
if (AS && !act) {
act = 1;
ACT = 1;
if (inlet_start) {
MidiSend1((midi_device_t)attr_device, MIDI_START);
} else {
MidiSend1((midi_device_t)attr_device, MIDI_CONTINUE);
}
MidiSend3((midi_device_t)attr_device, MIDI_SONG_POSITION,
inlet_position & 127, inlet_position >> 7);
pos = inlet_position;
} else if (!AS) {
act = 0;
}
if (inlet_stop && !stop) {
stop = 1;
ACT = 0;
MidiSend1((midi_device_t)attr_device, MIDI_STOP);
} else if (!inlet_stop) {
stop = 0;
}
outlet_active = ACT;
outlet_clock = 0;
if (ACT) {
if (!(inlet_position == pos)) {
MidiSend3((midi_device_t)attr_device, MIDI_SONG_POSITION,
inlet_position & 127, inlet_position >> 7);
}
if (inlet_clock && !trg) {
trg = 1;
MidiSend1((midi_device_t)attr_device, MIDI_TIMING_CLOCK);
outlet_clock = 1;
} else if (!inlet_clock) {
trg = 0;
}
}
outlet_reset = 0;
outlet_random = 0;
int RST = inlet_reset + (inlet_random << 1) + (inlet_trg1 << 2) +
(inlet_trg2 << 3) + (inlet_trg3 << 4);
if ((RST > 0) && !rst) {
rst = 1;
if (inlet_reset) {
outlet_reset = 1;
}
if (inlet_random) {
outlet_random = 1;
}
MidiSend3((midi_device_t)attr_device, MIDI_CONTROL_CHANGE + (attr_CH - 1),
attr_CC, __USAT(RST, 7));
} else if ((RST < 1) && rst) {
rst = 0;
}
pos = inlet_position;