int32 BPM
bool32.rising reset phase
bool32 square wave
bool32 trips
bool32 fours
bool32 vari
int32 BPM
int32 vari
int32_t Phase;
uint32_t r;
int rate1 = 3;
int rate2 = 4;
Phase = 0;
r = 1;
{
int BPM = param_BPM + inlet_BPM;
BPM = BPM > 0 ? BPM : 1;
if (inlet_reset && r) {
Phase = 0;
r = 0;
} else {
if (!inlet_reset)
r = 1;
int32_t freq;
freq = (1 << 31) / (45000 / BPM);
Phase += freq >> 2;
}
outlet_beat = (Phase > 0) ? 1 : 0;
outlet_trips = ((Phase * rate1) > 0) ? 1 : 0;
outlet_fours = ((Phase * rate2) > 0) ? 1 : 0;
outlet_vari = ((Phase * param_vari) > 0) ? 1 : 0;
}