quadTable

table oscillator allowing a smooth mix between 4 waves at a time and a mix between sinewave and table. For a wavetable, use "TheCreator" module to create a big 1024-waveform wavetable.
Author: Remco van der Most
License: BSD
Github: sss/osc/quadTable.axo

Inlets

frac32buffer frequency

frac32buffer phase

frac32buffer sync

int32 preset1

int32 preset2

int32 preset3

int32 preset4

frac32 mix1

frac32 mix2

frac32 mixSine

frac32.bipolar pitch

Outlets

frac32buffer.bipolar sine wave

Parameters

int32 preset1

int32 preset2

int32 preset3

int32 preset4

int32 octSine

int32 SoftS

bool32.tgl AM

bool32.tgl sync

frac32.s.map.pitch pitch

frac32.s.map FMW

frac32.s.map PMW

frac32.s.map detune

frac32.u.map mix1

frac32.u.map mix2

frac32.u.map mixSine

Attributes

objref table

Declaration
uint32_t Phase[4];
int32_t mix1;
int32_t mix2;
int32_t mix3;
int32_t MIX1;
int32_t MIX2;
int32_t MIX3;
int32_t read1;
int32_t read2;
int32_t read3;
int32_t read4;
int i;
int Strig;
int16_t preset1;
int16_t preset2;
int16_t preset3;
int16_t preset4;
int32_t sync;
Init
for (i = 0; i < 4; i++) {
  Phase[i] = 0;
}
Control Rate
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq);

MIX1 = param_mix1 + inlet_mix1;
MIX1 = MIX1 > (1 << 27) ? (1 << 27) : (MIX1 < 0 ? 0 : MIX1);
MIX1 = MIX1 + ___SMMUL(MIX1 << 3, (1 << 26)) - (1 << 23);
MIX2 = param_mix2 + inlet_mix2;
MIX2 = MIX2 > (1 << 27) ? (1 << 27) : (MIX2 < 0 ? 0 : MIX2);
MIX3 = param_mixSine + inlet_mixSine;
MIX3 = MIX3 > (1 << 27) ? (1 << 27) : (MIX3 < 0 ? 0 : MIX3);
if (MIX1 > (1 << 27)) {
  preset1 = (param_preset1 + inlet_preset1) & 1023;
  preset3 = (param_preset3 + inlet_preset3) & 1023;
}
if (MIX1 < 0) {
  preset2 = (param_preset2 + inlet_preset2) & 1023;
  preset4 = (param_preset4 + inlet_preset4) & 1023;
}
MIX1 = __USAT(MIX1, 27);
Audio Rate
int32_t Freq =
    freq + ___SMMUL(___SMMUL(inlet_freq << 5, freq << 4), param_FMW << 4);
sync = sync + ((inlet_sync - sync) >> param_SoftS);
if (param_sync > 0) {
  if ((sync > 0) && !Strig) {
    Phase[0] = 0;
    Phase[1] = 0;
    Phase[2] = 0;
    Phase[3] = 0;
    Strig = 1;
  } else if (sync < 1) {
    Strig = 0;
  }
}
int32_t phase = ___SMMUL(inlet_phase << 4, param_PMW << 4) << 1;
for (i = 0; i < 4; i++) {
  Phase[i] += Freq + ___SMMUL(Freq >> 2, param_detune >> 1) * i;
}
int32_t r;

int32_t p2 = Phase[0] + phase;
SINE2TINTERP((p2) << param_octSine, r)
read1 = ((((Phase[0] + (phase)) >> 22) & 1023) + (preset1 << 10)) &
        attr_table.LENGTHMASK;
read2 = ((((Phase[1] + (phase)) >> 22) & 1023) + (preset2 << 10)) &
        attr_table.LENGTHMASK;
read3 = ((((Phase[2] + (phase)) >> 22) & 1023) + (preset3 << 10)) &
        attr_table.LENGTHMASK;
read4 = ((((Phase[3] + (phase)) >> 22) & 1023) + (preset4 << 10)) &
        attr_table.LENGTHMASK;
int32_t ccomp1 = (1 << 27) - MIX1;
int32_t ccomp2 = (1 << 27) - MIX2;
mix1 = ___SMMUL(ccomp1 << 3, attr_table.array[read1] << 2) +
       ___SMMUL(MIX1 << 3, attr_table.array[read2] << 2);
mix2 = ___SMMUL(ccomp1 << 3, attr_table.array[read3] << 2) +
       ___SMMUL(MIX1 << 3, attr_table.array[read4] << 2);
mix3 = ___SMMUL(ccomp2 << 3, mix1 << 2) + ___SMMUL(MIX2 << 3, mix2 << 2);

outlet_wave = (___SMMUL(mix3 << 3, MIX3 << 3) + ___SMMUL(r, (1 << 27) - MIX3));
if (param_AM == 1) {
  outlet_wave = ___SMMUL(outlet_wave << 3, sync << 2);
}

Privacy

© 2024 Zrna Research