ldrive 1shot

drives a phasor (saw-wave) for reading/writing data
Author: robert schirmer
License: BSD
Github: rbrt/looper/ldrive 1shot.axo

Inlets

frac32.positive offset inside the table

frac32.positive length of the area to index,or loop end

frac32.positive position inside range on reset

frac32.bipolar speed modulation

bool32.rising trigger playback

Outlets

bool32 playback state

frac32buffer.positive relative position inside table

int32 playhead position inside range in samples

int32 length of range in samples

frac32.bipolar total speed

Parameters

frac32.s.map speed ,+ 64 normal speed forward, - 64 backward

Attributes

objref table

Declaration
int32_t index;
uint8_t shift;

int ntrig;

int32_t t_speed;
int32_t re;
int32_t rs;

int32_t start;
int32_t loopstart;
int32_t lrange;

bool play;
Init
shift = (27 - attr_table.LENGTHPOW);
Control Rate
// scale ranges up 8 times to achieve decent resolution for parameter speed
lrange = inlet_range << 3;
start = ___SMMUL(inlet_range, inlet_startpoint) << 8;
re = (t_speed > 0) ? lrange - (4 << shift) : lrange;
rs = (t_speed > 0) ? start : start - (4 << shift);
t_speed = (((inlet_speed + param_speed) << 3) >> attr_table.LENGTHPOW) +
          ((inlet_speed + param_speed) > 0);

if (inlet_play && (!ntrig)) {
  ntrig = 1;
  index = (t_speed < 0) ? lrange : start;
  play = 1;
} else if (!(inlet_play > 0))
  ntrig = 0;

if (!inlet_range)
  play = 0;

outlet_spos = (((index >> 3) >> shift) > 0) ? ((index >> 3) >> shift) : 0;
outlet_stotal = inlet_range >> shift;
outlet_speed = inlet_speed + param_speed;
outlet_play = play;
Audio Rate
if ((index > re) || (index < rs))
  play = 0;

if (play) {
  outlet_pos = __USAT(((index >> 3) + inlet_offset), 27);
  index += t_speed;
} else
  outlet_pos = 1 << 27;

Privacy

© 2024 Zrna Research