tableOS

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

Inlets

frac32 pitch

frac32 preset

frac32 mix

Outlets

frac32buffer wave

Parameters

int32 OS

frac32.s.map.pitch pitch

frac32.u.map preset

frac32.u.map mix

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_preset + inlet_preset & ((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_r = ___SMMUL(tmp_a11, tmp_w1);
  int32_t sine;
  SINE2TINTERP(phase, sine)
  tmp_r = ___SMMUL(Mix, ___SMMLA(tmp_a21, tmp_w2, tmp_r) << 2) +
          ___SMMUL(iMix, sine >> 5);
  outlet_out += tmp_r / param_OS;
}

Privacy

© 2024 Zrna Research