classic2

sine wave based internal PM/FM oscillator Though the knobs tell their independent function when the rest is set to zero, there is a lot of cross-influencing between the wave-morphs.
Author: Remco van der Most
License: BSD
Github: sss/osc/classic2.axo

Inlets

frac32.bipolar pitch

frac32buffer frequency

frac32buffer phase

frac32buffer sync

frac32 saw

frac32 pls

frac32 shark

frac32 p2s

frac32 rate

bool32 trig

Outlets

frac32buffer.bipolar sine wave

frac32 duck

frac32buffer phase

Parameters

frac32.s.map.pitch pitch

frac32.s.map.pitch softsync

int32 sets frequency-division for sub-harmonics

int32 OS

int32 wave

frac32.s.map saw-wave amount: feeds the output back into the phase of the sineshaper. creating a saw-wave. The higher the amount, the weirder the other parameters behave!

frac32.s.map shark-wave amount, flatens/steepens the frequency roll-off

frac32.s.map rate

frac32.u.map pulse-wave: multiplies the phase of the pulse, creating a strong frequency peak in the higher harmonics

frac32.u.map changes phase position of the shark, turning it from square-like to peak-like (expo triangle)

bool32.tgl track

Declaration
int i, snc;
uint32_t Phase;
int32_t sync;
int32_t phs;
int32_t r;
int32_t t1;
int32_t t2;
int32_t t3;
int32_t t4;
int32_t val;
int32_t hp;
int32_t vil;
int32_t pv[4];
int32_t stp[4];
int32_t v26 = (1 << 26);
int32_t v27 = (1 << 27);
int32_t v28 = (1 << 28);
int32_t v29 = (1 << 29);
int32_t v30 = (1 << 30);
int32_t Phs;
int32_t SHAPE(int32_t P, int md) {
  switch (md) {
  case 0:
    Phs = P;
    break;
  case 1:
    Phs = -P;
    break;
  case 2:
    Phs = P > 0 ? P : -P;
    break;
  case 3:
    SINE2TINTERP(P, Phs);
    break;
  case 4:
    Phs = P > 0 ? (1 << 30) : -(1 << 30);
    break;
  }
}
bool trg;
Init
Phase = 0;
Control Rate
int32_t freq;
int32_t rate;
MTOF(param_softsync, rate)
int32_t pitch = __SSAT(param_pitch + inlet_pitch, 28);
MTOFEXTENDED(pitch, freq);
freq = freq / param_div >> param_OS;
int32_t nyq;
MTOF(56, nyq)
nyq = nyq;
int32_t width;
int32_t iwidth;
int32_t tmp;
MTOF(56 << 21, tmp)
int32_t dck;
MTOF(__SSAT((v26) + pitch, 29), dck)
int32_t norm;
MTOF(-52 << 21, norm)
float32_t ratio = (float32_t)(norm) / (dck);
float32_t iratio = 1 - ratio;
// ratio=ratio*ratio;
iratio = 1 - iratio * iratio;

int32_t SAW = param_saw + inlet_saw;
int32_t PLS = (param_pls + inlet_pls) + pitch * param_track >> 1;
PLS = PLS & ((v28)-1);
PLS = PLS > (v27) ? (v28)-PLS : PLS;
int32_t SHARK = param_shark + inlet_shark;
int32_t P2S = param_p2s + inlet_p2s << 3;

int32_t super;
MTOFEXTENDED(param_rate + inlet_rate, super)
super = (super >> param_OS) >> 12;

iwidth = (v29) - (v29)*iratio;
width = (v29) - (v29)*ratio;
SAW = ___SMMUL(SAW << 3, iwidth << 1) << 2;
PLS = ___SMMUL(PLS << 3, PLS << 2);
if (param_track > 0) {
  MTOF(PLS, PLS);
}
PLS = ___SMMUL(PLS << 1, width) << 3;
SHARK = ___SMMUL(SHARK << 2, iwidth) << 3;

outlet_duck = width >> 3;

stp[0] = (SAW - pv[0]) >> 4;
stp[1] = (PLS - pv[1]) >> 4;
stp[2] = (SHARK - pv[2]) >> 4;
stp[3] = (P2S - pv[3]) >> 4;
int32_t saw = pv[0];
int32_t pls = pv[1];
int32_t shark = pv[2];
int32_t p2s = pv[3];
pv[0] = SAW;
pv[1] = PLS;
pv[2] = SHARK;
pv[3] = P2S;

if ((inlet_trig > 0) && !trg) {
  trg = 1;
  Phase = 0;
  phs = 0;
} else if (inlet_trig == 0) {
  trg = 0;
}
Audio Rate
int32_t out;
int32_t MOD = inlet_freq;
hp += MOD - hp >> 8;
MOD -= hp;
for (i = 0; i < (1 << param_OS); i++) {
  sync -= ___SMMUL(sync, rate);
  phs += super;

  if ((inlet_sync > 0) && !snc) {
    snc = 1;
    sync += Phase;
    Phase = 0;
  } else if (inlet_sync < 0) {
    snc = 0;
  }
  SHAPE(phs, param_wave);
  Phase += freq + (___SMMUL(freq, MOD) << 8);
  int32_t p2 = sync + Phase + (inlet_phase << 8);
  uint32_t p3 = p2 + (t1 << 1) + t2 + (t3 << 3);
  SINE2TINTERP((p3 * param_div + (t4 << 8) + Phs), r)
  int32_t s;
  SINE2TINTERP(p3 + (p2s), s)
  out = r;
  t2 += t1 - t2 >> 1;
  t1 += ___SMMUL(r, saw) - t1 >> 2;
  r = ___SMMUL(s, r);
  t3 += (___SMMUL(shark, r - (v30))) - t3 >> 4;
  r = ___SMMUL(s, s);
  t4 += (___SMMUL(pls, r - (3 << 29))) - t4 >> 4;
  val += ((out >> 4) - val) >> 1 + param_OS;
  vil += (val - vil) >> 10 + param_OS;
}
outlet_wave = (val)-vil >> 1;
outlet_phase = (sync + Phase) * param_div >> 5;

saw += stp[0];
pls += stp[1];
shark += stp[2];
p2s += stp[3];

Privacy

© 2024 Zrna Research