tri

triangle wave LFO, pitch input
Author: Peter Witzel
License: CC0
Github: cpwitz/lfo/tri.axo

Inlets

frac32.bipolar pitch

bool32.rising reset phase

Outlets

frac32.bipolar triangle wave

Parameters

frac32.s.map.lfopitch pitch

Declaration
int32_t phase;
uint32_t r;
Init
phase = 3 << 30;
r = 1;
Control Rate
{
  if (inlet_reset && r) {
    phase = 3 << 30;
    r = 0;
  } else {
    if (!inlet_reset)
      r = 1;
    uint32_t freq;
    MTOFEXTENDED(param_pitch + inlet_pitch, freq);
    phase += freq >> 2;
  }
  if (phase > 0) {
    outlet_wave = ((1 << 30) - (phase)) >> 3;
  } else {
    outlet_wave = (phase + (1 << 30)) >> 3;
  }
}

Privacy

© 2024 Zrna Research