pllSine

sine wave oscillator with PLL function and frequency modulation with frequency dependent modulation index
Author: Remco van der Most
License: BSD
Github: sss/osc/pllSine.axo

Inlets

frac32.bipolar pitch

frac32buffer frequency

frac32buffer phase

bool32 active

Outlets

frac32buffer.bipolar sine wave

Parameters

frac32.s.map.pitch pitch

frac32.s.map power

frac32.s.map overtones

frac32.s.map FM

bool32.tgl mode

Declaration
uint32_t Phase;
int32_t prev;
int32_t diff;
int32_t power;
int64_t r;
int32_t p2;
int32_t overtones;
int64_t val1;
int64_t val2;
int64_t out;
int32_t FM;
int64_t freq;
Init
Phase = 0;
Control Rate
if (inlet_active > 0) {
  MTOFEXTENDED(param_pitch + inlet_pitch, freq);
}
Audio Rate
if (inlet_active > 0) {
  diff = ((inlet_PLLphase << 4) - Phase) & ((1 << 32) - 1);
  diff = diff;
  power = ___SMMUL(param_power, diff);
  power = ___SMMUL(power << 3, power << 2);
  if (param_mode == 0) {
    if (diff > prev) {
      Phase += (power);
    }
    if (diff < prev) {
      Phase -= (power);
    }
  } else {
    if (diff > prev) {
      Phase -= (power);
    }
    if (diff < prev) {
      Phase += (power);
    }
  }
  prev = diff;
  FM = ___SMMUL(inlet_freq << 4, param_FM << 4);
  Phase += (freq + ___SMMUL(freq << 5, FM));
  val1 = val1 + ((param_overtones - val1) >> 7);
  p2 = Phase;
  SINE2TINTERP(p2, r)
  overtones = ___SMMUL(r, val1 << 4);
  SINE2TINTERP(p2 + (overtones << 4), r)
  val2 = val2 + (((r << 32) - val2) >> 2);
  out = val2 >> 38;
  outlet_wave = out;
}

Privacy

© 2024 Zrna Research