quadTable2

extended quadtable oscillator allowing a smooth mix between 4 waves at a time and a mix between 4 sinewaves and table, each on their own semitone and harmonic offset. For a wavetable, use "TheCreator" module to create a big 1024-waveform wavetable.
Author: Remco van der Most
License: BSD
Github: sss/osc/quadTable2.axo

Inlets

frac32 pitch

frac32 mix1

frac32 mix2

frac32 mixSine

frac32 sineABCD

frac32 sineACBD

frac32buffer frequency

frac32buffer phase

frac32buffer sync

int32 preset1

int32 preset2

int32 preset3

int32 preset4

Outlets

frac32buffer.bipolar sine wave

Parameters

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

frac32.u.map sineABCD

frac32.u.map sineACBD

bool32.tgl stay1

bool32.tgl stay2

bool32.tgl stay3

bool32.tgl stay4

bool32.tgl AM

bool32.tgl sync

int32 semi1

int32 hrm1

int32 hrmSine1

int32 preset1

int32 semi2

int32 hrm2

int32 hrmSine2

int32 preset2

int32 semi3

int32 hrm3

int32 hrmSine3

int32 preset3

int32 semi4

int32 hrm4

int32 hrmSine4

int32 preset4

int32 SoftS

int32.hradio S1

int32.hradio S2

int32.hradio S3

int32.hradio S4

Attributes

objref table

Declaration
uint32_t Phase[4];
int32_t mix1;
int32_t mix2;
int32_t mix3;
int32_t mix4;
int32_t mix5;
int32_t mix6;
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;
int16_t preset1;
int16_t preset2;
int16_t preset3;
int16_t preset4;
int32_t sync;
int strig1;
int strig2;
int strig3;
int strig4;
int32_t ofs[4];
int32_t Freq[4];
int32_t r[4];
int32_t p1;
int32_t hrmSine[4];
int mtrig[4];
Init
for (i = 0; i < 4; i++) {
  Phase[i] = 0;
}
Control Rate
int32_t pitch = inlet_pitch;

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)) && !mtrig[0]) {
  Preset1 = (inlet_preset1);
  Preset3 = (inlet_preset3);
  mtrig[0] = 1;
} else if (MIX1 < (1 << 27)) {
  mtrig[0] = 0;
}

if ((MIX1 < 0) && !mtrig[1]) {
  Preset2 = (inlet_preset2);
  Preset4 = (inlet_preset4);
  mtrig[1] = 1;
} else if (MIX1 > 0) {
  mtrig[1] = 0;
}

if ((MIX2 > (1 << 27)) && !mtrig[2]) {
  Preset1 = (inlet_preset1);
  Preset2 = (inlet_preset2);
  mtrig[2] = 1;
} else if (MIX2 < (1 << 27)) {
  mtrig[2] = 0;
}

if ((MIX2 < 0) && !mtrig[3]) {
  Preset3 = (inlet_preset3);
  Preset4 = (inlet_preset4);
  mtrig[3] = 1;
} else if (MIX2 > 0) {
  mtrig[3] = 0;
}

MIX1 = __USAT(MIX1, 27);
preset1 = (Preset1 + param_preset1) & attr_table.LENGTHMASK;
preset2 = (Preset2 + param_preset2) & attr_table.LENGTHMASK;
preset3 = (Preset3 + param_preset3) & attr_table.LENGTHMASK;
preset4 = (Preset4 + param_preset4) & attr_table.LENGTHMASK;
int32_t Pitch1;
int32_t Pitch2;
int32_t Pitch3;
int32_t Pitch4;
int divisor = 12 << 21;
if (param_stay1 > 0) {
  Pitch1 = (pitch - (pitch / divisor) * divisor);
  Pitch1 += Pitch1 < 0 ? (12 << 21) : 0;
  Pitch1 += param_pitch;
} else {
  Pitch1 = pitch + param_pitch;
}

if (param_stay2 > 0) {
  Pitch2 = (pitch - (pitch / divisor) * divisor);
  Pitch2 += Pitch2 < 0 ? (12 << 21) : 0;
  Pitch2 += param_pitch;
} else {
  Pitch2 = pitch + param_pitch;
}

if (param_stay3 > 0) {
  Pitch3 = (pitch - (pitch / divisor) * divisor);
  Pitch3 += Pitch3 < 0 ? (12 << 21) : 0;
  Pitch3 += param_pitch;
} else {
  Pitch3 = pitch + param_pitch;
}

if (param_stay4 > 0) {
  Pitch4 = (pitch - (pitch / divisor) * divisor);
  Pitch4 += Pitch4 < 0 ? (12 << 21) : 0;
  Pitch4 += param_pitch;
} else {
  Pitch4 = pitch + param_pitch;
}

MTOFEXTENDED((Pitch1 + (param_semi1 << 21)), ofs[0])
MTOFEXTENDED((Pitch2 + (param_semi2 << 21)), ofs[1])
MTOFEXTENDED((Pitch3 + (param_semi3 << 21)), ofs[2])
MTOFEXTENDED((Pitch4 + (param_semi4 << 21)), ofs[3])

int32_t ccomp1 = (1 << 27) - MIX1;
int32_t ccomp2 = (1 << 27) - MIX2;
int32_t MIX4 = __USAT(param_sineABCD + inlet_sineABCD, 27);
int32_t MIX5 = __USAT(param_sineACBD + inlet_sineACBD, 27);
int32_t ccomp3 = (1 << 27) - MIX4;
int32_t ccomp4 = (1 << 27) - MIX5;
hrmSine[0] = param_hrmSine1;
hrmSine[1] = param_hrmSine2;
hrmSine[2] = param_hrmSine3;
hrmSine[3] = param_hrmSine4;
Audio Rate
sync = sync + ((inlet_sync - sync) >> param_SoftS);

if ((param_S1 > 0) && (Phase[param_S1] > (1 << 31)) && (!strig1)) {
  Phase[0] = 0;
  strig1 = 1;
} else if ((Phase[0] > (3 << 30)) & (!(Phase[param_S1] > (1 << 31)))) {
  strig1 = 0;
}

if ((param_S2 > 0) && (Phase[param_S2 + 1 & 3] > (1 << 31)) && (!strig2)) {
  Phase[1] = 0;
  strig2 = 1;
} else if ((Phase[1] > (3 << 30)) & (!(Phase[param_S2 + 1 & 3] > (1 << 31)))) {
  strig2 = 0;
}

if ((param_S3 > 0) && (Phase[param_S3 + 2 & 3] > (1 << 31)) && (!strig3)) {
  Phase[2] = 0;
  strig3 = 1;
} else if ((Phase[2] > (3 << 30)) & (!(Phase[param_S3 + 2 & 3] > (1 << 31)))) {
  strig3 = 0;
}

if ((param_S4 > 0) && (Phase[param_S4 + 3 & 3] > (1 << 31)) && (!strig4)) {
  Phase[3] = 0;
  strig4 = 1;
} else if ((Phase[3] > (3 << 30)) & (!(Phase[param_S4 + 3 & 3] > (1 << 31)))) {
  strig4 = 0;
}

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++) {
  Freq[i] =
      ofs[i] + ___SMMUL(___SMMUL(inlet_freq << 5, ofs[i] << 4), param_FMW << 4);
  Phase[i] += Freq[i] + ___SMMUL(Freq[i] >> 2, param_detune >> 1) * i;
  p1 = Phase[i] + phase;
  SINE2TINTERP(p1 << hrmSine[i], r[i])
}

read1 = ((((Phase[0] + (phase)) * param_hrm1 >> 22) & 1023) + (preset1 << 10)) &
        attr_table.LENGTHMASK;
read2 = ((((Phase[1] + (phase)) * param_hrm2 >> 22) & 1023) + (preset2 << 10)) &
        attr_table.LENGTHMASK;
read3 = ((((Phase[2] + (phase)) * param_hrm3 >> 22) & 1023) + (preset3 << 10)) &
        attr_table.LENGTHMASK;
read4 = ((((Phase[3] + (phase)) * param_hrm4 >> 22) & 1023) + (preset4 << 10)) &
        attr_table.LENGTHMASK;

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 << 2, mix1 << 2) + ___SMMUL(MIX2 << 2, mix2 << 2);

mix4 = ___SMMUL(ccomp3, r[0]) + ___SMMUL(MIX4, r[1]);
mix5 = ___SMMUL(ccomp3, r[2]) + ___SMMUL(MIX4, r[3]);
mix6 = ___SMMUL(ccomp4 << 3, mix4 << 2) + ___SMMUL(MIX5 << 3, mix5 << 2);
outlet_wave =
    (___SMMUL(mix3 << 3, MIX3 << 3) + ___SMMUL(mix6 << 3, ((1 << 27) - MIX3))
     << 2);
if (param_AM == 1) {
  outlet_wave = ___SMMUL(outlet_wave << 3, sync << 2);
}

Privacy

© 2024 Zrna Research