sphasor scaled

48000 at 'inlet_smps' will result in a 1 hz-saw-wave. '1barLength' defines the maximum length of 1 bar in seconds, longer inputs at 'inlet_smps' will scale up the speed. a pulse at 'rphase' will reset the phase, a pulse at 'rspeed' will recalculate the speed.
Author: robert schirmer
License: BSD
Github: rbrt/lfo/sphasor scaled.axo

Inlets

int32 samples in

bool32.rising rphase

bool32.rising reset phase

int32.positive 1barLength

Outlets

frac32.positive phase

Declaration
uint32_t Phase;
uint64_t freq;
bool rphase;
bool rspeed;
Init
Phase = 0;
Control Rate
if (inlet_rspeed && !rspeed) {
  freq = (int)((281474976710656.f / (inlet_smps * (128 << 3))) *
               ((((unsigned int)inlet_smps) / (inlet_1barLength * 48000)) + 1));
  rspeed = 1;
}
if (inlet_rphase && !rphase) {
  Phase = 0;
  rphase = 1;
}
Phase += freq >> 2;
outlet_wave = (Phase >> 5) & ((1 << 27) - 1);

if (!inlet_rphase)
  rphase = 0;
if (!inlet_rspeed)
  rspeed = 0;

Privacy

© 2024 Zrna Research