ldrive loop

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

Inlets

frac32.bipolar speed modulation

bool32.risingfalling toggle playback

bool32.rising reset to 'offset'

bool32.rising reset to 'startpoint'

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.positive loopstart inside range

Outlets

frac32buffer.positive relative position inside table

int32 loop count since reset

int32 playhead position inside range in samples

int32 length of range in samples

int32 length of loop in samples

frac32.bipolar total speed

Parameters

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

Attributes

objref table

Declaration
int32_t index;
bool rrs;
bool rro;
uint8_t shift;

int ntrig;

int32_t t_speed;
int32_t re;
int32_t rs;

int32_t start;
int32_t loopstart;
int32_t lrange;
int32_t lstart;

uint32_t count;
bool add;
bool play;
bool mode;
Init
shift = (27 - attr_table.LENGTHPOW);
Control Rate
loopstart = ___SMMUL(inlet_range, inlet_loopstart) << 5;
add = inlet_range;
// scale ranges up 8 times to achieve decent resolution for parameter speed
lrange = inlet_range << 3;
lstart = loopstart << 3;
start = ___SMMUL(inlet_range, inlet_startpoint) << 8;
t_speed = (((inlet_speed + param_speed) << 3) >> attr_table.LENGTHPOW) +
          ((inlet_speed + param_speed) > 0);

play = inlet_play;
if (inlet_r2start && (!rrs)) {
  index = start;
  rrs = 1;
  count = 0;
}
if (inlet_r2offset && (!rro)) {
  index = 0;
  rro = 1;
  count = 0;
}
if (!inlet_r2offset)
  rro = 0;
if (!inlet_r2start)
  rrs = 0;

if (!inlet_range)
  play = 0;

outlet_count = (inlet_play) ? count : -1;
outlet_spos = (((index >> 3) >> shift) > 0) ? ((index >> 3) >> shift) : 0;
outlet_stotal = inlet_range >> shift;
outlet_sloop = (inlet_range - loopstart) >> shift;
outlet_speed = inlet_speed + param_speed;
Audio Rate
if (t_speed > 0) {
  if (index >= lrange) {
    index = lstart;
    count += add;
  }
} else {
  if (index <= lstart) {
    index = lrange;
    count += add;
  }
}

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

Privacy

© 2024 Zrna Research