spectralOscillator

Spectral Oscillator with up to 32 harmonics. Depending on the jump, offset and range parameters, the oscillator creates different waveforms.
Author: Remco van der Most
License: BSD
Github: sss/osc/spectralOscillator.axo

Inlets

bool32 active

frac32 pitch

frac32buffer freq

int32 start

int32 jump

int32 offset

int32 after

int32 expo

frac32.positive damp

Outlets

frac32buffer out

Parameters

frac32.s.map.pitch pitch

frac32.s.map FM

int32 harmonics

int32 start

int32 jump

int32 offset

int32 after

int32 expo

int32 range

frac32.u.map damp

Declaration
int32_t _Phase[32];
int32_t _sine[32];
int32_t _harm[32];
int32_t _Ranged[32];
int32_t phase;

int32_t range;
int64_t sum;
int32_t Ranged;
int32_t FM;
int32_t jump;
int32_t offset;
int32_t after;
int32_t start;
int32_t expo;
uint32_t damp;
int32_t freq;
Control Rate
if (inlet_active > 0) {
  MTOF(param_pitch + inlet_pitch, freq)

  range = param_range;

  jump = inlet_jump + param_jump;
  offset = param_offset + inlet_offset;
  after = param_after + inlet_after;
  start = inlet_start + param_start;
  expo = inlet_expo + param_expo;
}
Audio Rate
if (inlet_active > 0) {
  FM = ___SMMUL(inlet_freq << 3, param_FM << 3);
  phase += freq + ___SMMUL(freq << 8, FM << 4);
  damp = inlet_damp + param_damp;
  sum = 0;
  for (int i = 0; i <= param_harmonics; i++) {
    _sine[i] = 0;
    SINE2TINTERP(phase +
                     phase * (((i + start) * jump +
                               ((i + start) >> after) * offset + i * i * expo) &
                              ((1 << range) - 1)) +
                     (((i + start) * jump +
                           (((i + start) >> after) * offset + i * i * expo) &
                       1)
                      << 30),
                 _sine[i])
    sum += (_sine[i < param_harmonics ? i : param_harmonics] >> 5) /
           (1 + ___SMMUL(i << 8, damp));
  }

  outlet_out = sum >> 2;
}

Privacy

© 2024 Zrna Research