frac32.positive GainTimbre
frac32.positive GainColor
frac32.positive GainFrequency
frac32.positive GainReso
frac32.positive GainVCA
bool32.rising Trigger
frac32 In
frac32.bipolar OutTimbre
frac32.bipolar OutColor
frac32.bipolar OutFrequency
frac32.bipolar OutReso
frac32.bipolar OutVCA
int ntrig;
int latch;
float speedup;
float speeddown;
float rangeup;
float rangedown;
float out;
if ((inlet_Trigger > 0) && !ntrig) {
latch = inlet_In;
ntrig = 1;
rangeup = (0x07FFFFFF - latch);
rangedown = (latch - 0);
speedup =
(float)(134217728 / (rangeup + 1)); // add one to prevent divide by zero
speeddown =
(float)(134217728 / (rangedown + 1)); // add one to prevent divide by zero
}
if (!(inlet_Trigger > 0)) {
ntrig = 0;
}
float reduced = inlet_i - latch;
if (reduced > 0) {
out = (float)(reduced * speedup);
}
if (!(reduced > 0)) {
out = (float)(reduced * speeddown);
}
outlet_OutTimbre = ___SMMUL(out, inlet_GainTimbre) << 5;
outlet_OutColor = ___SMMUL(out, inlet_GainColor) << 5;
outlet_OutFrequency = ___SMMUL(out, inlet_GainFrequency) << 5;
outlet_OutReso = ___SMMUL(out, inlet_GainReso) << 5;
outlet_OutVCA = ___SMMUL(out, inlet_GainVCA) << 5;