sphasor

saw wave signal-rate LFO, rising slope, sample input. 48000 at inlet 'smps' will result in a 1 hz-saw-wave. use 'inlet_mul' to time-scale the output.
Author: robert schirmer
License: BSD
Github: rbrt/lfo/sphasor.axo

Inlets

int32 samples in

int32.positive multiplier.defaults to 1.

bool32.rising reset phase

Outlets

frac32.positive phase

Declaration
uint32_t Phase;
uint64_t freq;
uint32_t r;
uint8_t mul;
Init
Phase = 0;
r = 1;
Control Rate
mul = (inlet_mul > 0) ? inlet_mul : 1;
freq = (int)(281474976710656.f / (inlet_smps * (128 << 3)));

if (inlet_reset && r) {
  Phase = 0;
  r = 0;
} else {
  if (!inlet_reset)
    r = 1;
  Phase += freq >> 2;
}
outlet_wave = ((Phase >> 5) * mul) & ((1 << 27) - 1);

Privacy

© 2024 Zrna Research