tableOS2

simple, up to 16x oversampled, wavetable oscillator, able to use wavetables from the waveformLoader, waveformGenerator, waveformGuitar and waveformRandom modules. "mix" mixes from preset1 to preset2.
Author: Remco van der Most
License: BSD
Github: sss/osc/tableOS2.axo

Inlets

frac32 pitch

frac32 preset1

frac32 preset2

frac32 mix

Outlets

frac32buffer wave

Parameters

frac32.u.map preset1

frac32.u.map mix

frac32.u.map preset2

int32 OS

frac32.s.map.pitch pitch

Attributes

objref table

Declaration
uint32_t phase;
int i;
int32_t prev;
int32_t step;
Control Rate
int32_t freq;
MTOFEXTENDED(param_pitch + inlet_pitch, freq)
freq = freq / param_OS;
int32_t preset1 =
    ___SMMUL((param_preset1 + inlet_preset1 & ((1 << 27) - 1)) << 3,
             attr_table.Waveforms - 1 << 2) *
    attr_table.LENGTH;
int32_t preset2 =
    ___SMMUL((param_preset2 + inlet_preset2 & ((1 << 27) - 1)) << 3,
             attr_table.Waveforms - 1 << 2) *
    attr_table.LENGTH;
int32_t mix = __USAT(param_mix + inlet_mix, 27) << 3;
step = ((mix - prev) >> 4) / param_OS;
int32_t Mix = prev;
prev = mix;
Audio Rate
outlet_out = 0;

for (i = 0; i < param_OS; i++) {
  Mix += step;
  int32_t iMix = (1 << 30) - Mix;
  phase += freq;
  uint32_t tmp_d = phase >> 5;
  uint32_t tmp_di = (tmp_d >> (27 - attr_table.LENGTHPOW));
  uint32_t tmp_w1 = (tmp_d << (attr_table.LENGTHPOW + 3)) & 0x3FFFFFFF;
  uint32_t tmp_w2 = (1 << 30) - tmp_w1;
  int32_t tmp_a11 =
      attr_table.array[(tmp_di & attr_table.LENGTHMASK) + preset1];
  int32_t tmp_a21 =
      attr_table.array[((tmp_di + 1) & attr_table.LENGTHMASK) + preset1];
  int32_t tmp_a12 =
      attr_table.array[(tmp_di & attr_table.LENGTHMASK) + preset2];
  int32_t tmp_a22 =
      attr_table.array[((tmp_di + 1) & attr_table.LENGTHMASK) + preset2];
  tmp_a11 = ___SMMUL(iMix, tmp_a11 << 2) + ___SMMUL(Mix, tmp_a12 << 2);
  tmp_a21 = ___SMMUL(iMix, tmp_a21 << 2) + ___SMMUL(Mix, tmp_a22 << 2);
  int32_t tmp_r = ___SMMUL(tmp_a11, tmp_w1);
  tmp_r = ___SMMLA(tmp_a21, tmp_w2, tmp_r);
  outlet_out += tmp_r / param_OS;
}

Privacy

© 2024 Zrna Research