ldrive_smps

drives a phasor (saw-wave) for reading/writing data
Author: robert schirmer
License: BSD
Github: rbrt/testing/ldrive_smps.axo

Inlets

bool32.rising reset to 'offset'

int32.positive offset

int32.positive range

frac32.bipolar direction

frac32.positive tansposition in semi-notes

bool32.risingfalling toggle playback

Outlets

frac32buffer.positive position inside table

Attributes

objref table to index

spinner forward or reverse

Declaration
int32_t index;
int32_t pos;
uint8_t i_shift;
int32_t i_inc;
uint16_t l_div;
bool play;
bool rro;
Init
uint8_t t_length =
    ((22 - attr_wave.LENGTHPOW) > 2) ? 2 : 22 - attr_wave.LENGTHPOW;
l_div = 1428 >> t_length;
i_shift = 9 + t_length;
Control Rate
MTOFEXTENDED(inlet_transpose - (1 << 27), i_inc);
i_inc = ___SMMUL(i_inc, inlet_direction) << 5;
i_inc = i_inc / l_div;

if (inlet_play && !play) {
  play = 1;
  index = 0;
}
if (!inlet_play)
  play = 0;

if (inlet_reset && (!rro)) {
  index = 0;
  rro = 1;
}
if (!inlet_reset)
  rro = 0;
if (!inlet_range)
  play = 0;
Audio Rate
pos = index >> i_shift;
outlet_smps = (play) ? pos + inlet_offset : 0;
index += i_inc;
if (i_inc > 0) {
  if (pos >= inlet_range)
    index = 0;
} else if (pos <= 0)
  index = inlet_range << i_shift;

Privacy

© 2024 Zrna Research