Qsc

Author: Smashed Transistors
License: LGPL
Github: tiar/osc/Qsc.axo

Inlets

frac32.bipolar pitch

frac32.bipolar res

frac32.bipolar brill

Outlets

frac32buffer.bipolar out

Parameters

frac32.s.map.pitch pitch

frac32.u.map res

frac32.s.map brill

Attributes

combo Qres

Declaration
uint32_t pC;
int32_t dpC;
int32_t res;
float skew, _1skew, _skew;
float pMast;
float dpMast, _dpMast;
Init
pC = 0;
pMast = 0;
Control Rate
int32_t idp;
MTOFEXTENDED(inlet_pitch + param_pitch, idp);
dpMast = arm::q_to_float(idp, 32);
_dpMast = 1.0f / dpMast;

int32_t pBrill = inlet_brill + param_brill;
if (pBrill + inlet_pitch + param_pitch > (40 << 21)) {
  pBrill = (40 << 21) - inlet_pitch - param_pitch;
}
int32_t iBrill;
MTOFEXTENDED(-pBrill, iBrill);
float newSkew = arm::q_to_float(iBrill, 27);
if (newSkew > 0.5f)
  newSkew = 0.5f;
float new_skew = 1.0f / newSkew;
float res = arm::q_to_float(inlet_res + param_res, 27);
if (res < 0.0f)
  res = 0.0f;
float dpCf = 0.5f * 4294967296.0f * dpMast * new_skew;
dpC = (int32_t)dpCf;
float new_1skew = 1.0f / (1 - newSkew);
Audio Rate
// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

pMast += dpMast;
if (pMast > 1) {
  pMast -= 1;
  pC = (uint32_t)(pMast * _dpMast * dpCf - (1 << 31));
  skew = newSkew;
  _1skew = new_1skew;
  _skew = new_skew;
}

// simulated resonance signal is a slave sine oscillator
float y = arm::q_to_float(sine2t[pC >> 20], 31);

pC += dpC;

// skewed triangle
float e = pMast >= skew ? (1 - pMast) * _1skew : pMast * _skew;
y *= e;
#if attr_Qres == 1
y = y * (1.5f - 0.5f * y * y);
#elif attr_Qres == 2
y = y * (1.5f - 0.5f * y * y);
y = y * (1.5f - 0.5f * y * y);
#endif
// waveshaper
float es = e * e * (6 - 4 * e) - 1;
// outlet_out = (int32_t)(es * ((1<<27) + res * ( e * y - (1<<27))));
// outlet_out = (int32_t)(e*y);
outlet_out = arm::float_to_q(es + res * (y - es), 27);

Privacy

© 2024 Zrna Research