frac32buffer in
frac32buffer out
frac32.u.map gain
frac32.u.map powerP
frac32.u.map powerN
frac32.u.map TransistorGain
frac32.u.map TubeGain
int32_t powerP;
int32_t powerN;
int32_t capP;
int32_t capN;
int32_t valP;
int32_t valN;
int32_t trns = ___SMMUL(param_gain << 3, param_TransistorGain);
int32_t tube = ___SMMUL(param_gain << 3, param_TubeGain << 3);
int32_t ABS = inlet_in;
ABS = ABS > 0 ? ABS : -ABS;
int32_t takeP = (powerP - capP) >> 1;
int32_t takeN = (powerN - capN) >> 1;
powerP -= takeP;
powerN -= takeN;
capP += takeP;
capN += takeN;
powerP = __USAT(powerP + param_powerP, 28);
powerN = -__USAT(-powerN + param_powerN, 28);
int32_t transistor = ___SMMUL(trns << 3, capP << 2);
int32_t takeT = ___SMMUL(transistor << 3, ABS << 2);
takeT = takeT > capP ? capP : takeT;
capP = __USAT(capP - (takeT >> 2), 29);
takeT = ___SMMUL(transistor << 3, tube << 2);
takeP = ___SMMUL(takeT << 3, capP << 2);
takeN = ___SMMUL(takeT << 3, capN << 2);
takeP = takeP > capP ? capP : takeP;
takeN = takeN < capN ? capN : takeN;
takeP = ___SMMUL(takeP << 3, takeP << 2);
takeN = -___SMMUL(takeN << 3, takeN << 2);
capP -= ___SMMUL(takeP << 2, ABS << 3);
capN -= ___SMMUL(takeN << 2, ABS << 3);
int32_t out;
if (inlet_in > 0) {
out = ___SMMUL(inlet_in << 3, takeP << 2);
} else {
out = ___SMMUL(inlet_in << 3, -takeN << 2);
}
outlet_out = out;
// outlet_out=___SMMUL(inlet_in<<3,takeP+takeN)<<2;