sawtrimod2

supersaw/saw-tri-mod oscillator
Author: Remco van der Most
License: BSD
Github: sss/osc/sawtrimod2.axo

Inlets

frac32buffer input

frac32 detune

frac32 shapeA

frac32 shapeB

frac32 walk

frac32 modwidth

frac32 mod

frac32 pitch

frac32 LP

frac32 HP

Outlets

frac32buffer output

Declaration
uint32_t Phase;
int32_t pPhase;

int32_t val1;
int32_t val2;
Init
Phase = 0;
pPhase = 0;

val1 = 0;
val2 = 0;
Control Rate
int32_t freq;
MTOFEXTENDED(inlet_walk - (1 << 27) + inlet_pitch, freq);
Phase += freq >> 2;

pPhase = Phase;

int32_t f;
MTOF(inlet_pitch + inlet_HP, f);
int32_t g;
MTOF(inlet_pitch + inlet_LP, g);

int32_t detune = inlet_detune >> 10;
Audio Rate
int32_t phases;
int32_t phaset;
int32_t phaseu;
int32_t phasev;
int32_t phasew;
int32_t phasex;
int32_t phasey;
int32_t phasez;
int32_t sina;
int32_t sinb;
int32_t mixa;
int32_t mixb;
int32_t mixc;
int32_t mixd;
int32_t wa;
int32_t wb;
int32_t wc;
int32_t we;
int32_t wf;
int32_t phaseg1;
int32_t phaseg2;
int32_t phaseg3;
int32_t phaseg4;

phasez = ___SMMUL(inlet_modwidth << 3, inlet_mod << 2);

wa = (inlet_a + Phase) & ((1 << 27) - 1);
wb = (inlet_shapeA >> 1) + (1 << 26);
wc = (1 << 27) - (wb);

if (wa < wb) {
  phaseu = wa * ((1 << 30) / (wb)) >> 3;
} else {
  phaseu = (1 << 27) - ((wa - (wb)) * ((1 << 30) / wc) >> 3);
}

phasev =
    (phaseu + (wa > (wb) ? (___SMMUL(inlet_shapeB << 3, (wa - wb) << 4)) : 0));
phaset = (phasev > 0 ? phasev : -phasev) & ((1 << 27) - 1);

SINE2TINTERP((phaset << 4) - (1 << 30), sina)
mixa = (sina >> 6);

wa = (((inlet_a * (___SMMUL(2 << 16, detune << 2))) & ((1 << 27) - 1)) + Phase -
      phasez) &
     ((1 << 27) - 1);
wb = (inlet_shapeA >> 1) + (1 << 26) + (phasez >> 1);
wc = (1 << 27) - (wb);

if (wa < wb) {
  phaseu = wa * ((1 << 30) / (wb)) >> 3;
} else {
  phaseu = (1 << 27) - ((wa - (wb)) * ((1 << 30) / wc) >> 3);
}

phasev =
    (phaseu + (wa > (wb) ? (___SMMUL(inlet_shapeB << 3, (wa - wb) << 4)) : 0));
phaset = (phasev > 0 ? phasev : -phasev) & ((1 << 27) - 1);

SINE2TINTERP((phaset << 4) - (1 << 30), sina)
mixb = (sina >> 7);

wa =
    (((inlet_a * (___SMMUL(4 << 16, detune << 2))) & ((1 << 27) - 1)) + Phase) &
    ((1 << 27) - 1);
wb = (inlet_shapeA >> 1) + (1 << 26) - (phasez >> 1);
wc = (1 << 27) - (wb);

if (wa < wb) {
  phaseu = wa * ((1 << 30) / (wb)) >> 3;
} else {
  phaseu = (1 << 27) - ((wa - (wb)) * ((1 << 30) / wc) >> 3);
}

phasev =
    (phaseu + (wa > (wb) ? (___SMMUL(inlet_shapeB << 3, (wa - wb) << 4)) : 0));
phaset = (phasev > 0 ? phasev : -phasev) & ((1 << 27) - 1);

SINE2TINTERP((phaset << 4) - (1 << 30), sina)
mixc = (sina >> 8);

wa = (((inlet_a * (___SMMUL(8 << 16, detune << 2))) & ((1 << 27) - 1)) - Phase +
      inlet_mod) &
     ((1 << 27) - 1);
wb = (inlet_shapeA >> 1) + (1 << 26) - (phasez >> 2);
wc = (1 << 27) - (wb);

if (wa < wb) {
  phaseu = wa * ((1 << 30) / (wb)) >> 3;
} else {
  phaseu = (1 << 27) - ((wa - (wb)) * ((1 << 30) / wc) >> 3);
}

phasev =
    (phaseu + (wa > (wb) ? (___SMMUL(inlet_shapeB << 3, (wa - wb) << 4)) : 0));
phaset = (phasev > 0 ? phasev : -phasev) & ((1 << 27) - 1);

SINE2TINTERP((phaset << 4) - (1 << 30), sina)
mixd = (sina >> 9);

phasey = mixa + mixb + mixc + mixd;

val1 = ___SMMLA((phasey - val1) << 1, f, val1);

phasex = phasey - val1;

val2 = ___SMMLA((phasex - val2) << 1, g, val2);
outlet_result = val2;

Privacy

© 2024 Zrna Research