STO

sine wave oscillator
Author: Johannes Taelman
License: BSD
Github: sss/osc/STO.axo

Inlets

frac32 shape

frac32 sub

frac32 LP

frac32.bipolar pitch

Outlets

frac32buffer.bipolar sine wave

Parameters

frac32.u.map shape

frac32.u.map sub

frac32.s.map.pitch pitch

frac32.s.map.pitch LP

Declaration
uint32_t Phase;
int32_t prev1;
int32_t step1;
int32_t prev2;
int32_t step2;
int rtrig;
int32_t SQ;
int32_t sq;
Init
Phase = 0;
SQ = 0;
Control Rate
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq);
int32_t shape = inlet_shape + param_shape;
shape = shape & ((1 << 28) - 1);
shape = shape > (1 << 27) ? (1 << 28) - shape : shape;
step1 = (shape - prev1) >> 4;
int32_t i1 = prev1;
prev1 = shape;
step2 = (freq - prev2) >> 4;
int32_t i2 = prev2;
prev2 = freq;
int32_t F;
MTOF(param_LP + (inlet_LP << 1), F);
int32_t sub = param_sub + inlet_sub;
Audio Rate
i1 += step1;
i2 += step2;
Phase += i2;
int32_t r1;
int32_t r2;
int32_t p2 = Phase;
SINE2TINTERP(p2, r1)
r2 = Phase + (1 << 30);

if ((r1 > 0) && !rtrig) {
  rtrig = 1;
  sq += 1;
  sq = sq & 1;
} else if (r1 < 0) {
  rtrig = 0;
}

r2 = r2 > 0 ? r2 : -r2;
r2 = (r2) - (1 << 30);
int32_t temp = sq > 0 ? sub : -sub;
temp += ___SMMUL(r2, i1 << 2);
SQ = ___SMMLA((temp - SQ) << 1, F, SQ);
outlet_wave = (___SMMUL((r1 >> 1), ((1 << 27) - i1) << 2) + SQ) >> 1;

Privacy

© 2024 Zrna Research