monodualSine

sine/saw/dip oscillator based on self-FM and self-PM. Uses two phase-generators and mixes from old to new sine when gate-input goes high. This prevents clicking Also features self-modulation for creating saw/dip/combined waveforms
Author: Remco van der Most
License: BSD
Github: sss/osc/monodualSine.axo

Inlets

frac32.bipolar pitch

frac32buffer modulate PM for saw-waveform

frac32buffer modulate FM for dip-waveform

bool32 connect to gate (same as envelope)

Outlets

frac32buffer.bipolar sine wave

frac32buffer mix

Parameters

frac32.u.map fade

frac32.s.map.pitch pitch

frac32.s.map detune

frac32.s.map saw

frac32.s.map dip

Declaration
uint32_t Phs1;
uint32_t Phs2;
bool sel;
bool trg;
int32_t frq1;
int32_t frq2;
int32_t mix;
int32_t v30 = 1 << 30;
int32_t v19 = 1 << 19;
int32_t v27 = 1 << 27;
int32_t wave;
int32_t hp;
int32_t prv;
int32_t lp;
int32_t HP;
Init
Phs1 = 0;
Phs2 = 0;
Control Rate
int32_t detune = param_detune >> 7;
if ((inlet_gate > 0) && !trg) {
  trg = 1;
  sel = (int)((int)sel + 1) & 1;
  if (sel == 1) {
    Phs2 = Phs1;
    // MTOFEXTENDED(param_pitch + inlet_pitch,frq2);
  } else {
    Phs1 = Phs2;
    // MTOFEXTENDED(param_pitch + inlet_pitch,frq1);
  }
} else if (inlet_gate == 0) {
  trg = 0;
}

if (sel == 1) {
  MTOFEXTENDED(param_pitch + inlet_pitch + detune, frq2);
} else {
  MTOFEXTENDED(param_pitch + inlet_pitch, frq1);
}

int32_t rate = v19 + (v27 - param_fade >> 4);
Audio Rate
int32_t dip = param_dip + inlet_dip;
int32_t FM1 = ___SMMUL(dip, frq1) << 4;
int32_t FM2 = ___SMMUL(dip, frq2) << 4;

Phs1 += frq1 + (___SMMUL(wave, FM1) << 5);
Phs2 += frq2 + (___SMMUL(wave, FM2) << 5);
int32_t r1;
int32_t r2;
int32_t saw = inlet_saw + param_saw;
SINE2TINTERP(Phs1 + (___SMMUL(lp, saw) << 6), r1)
SINE2TINTERP(Phs2 + (___SMMUL(lp, saw) << 6), r2)
r1 = r1 >> 4;
r2 = r2 >> 4;
mix = __USAT(mix + (sel > 0 ? rate : -rate), 30);
wave = r1 + ___SMMUL(r2 - r1 << 2, mix);
int32_t ring = -___SMMUL(wave << 3, (wave > 0 ? wave : -wave) << 2);
HP += ring - HP >> 9;
ring -= HP;
outlet_wave = wave;
wave = wave + ring << 3;

hp += wave - hp >> 9;
wave -= hp;
lp += (wave - lp) >> 2;
wave = lp;
outlet_mix = mix >> 4;

Privacy

© 2024 Zrna Research