ldrive flex

drives a phasor (saw-wave) for reading/writing data
Author: robert schirmer
License: BSD
Github: rbrt/looper/ldrive flex.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.positive loopstart inside range

frac32.bipolar speed modulation

bool32.risingfalling playback mode; 0 = looped, 1 = 1-shot

bool32 toggle playback (looped);trigger playback (1-shot)

bool32.rising reset to 'offset'

bool32.rising reset to 'startpoint'

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

bool32 playback state

Parameters

bool32.tgl 1shot

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;
mode = inlet_1shot || param_1shot;
// 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;
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 (mode) {
  if (inlet_play && (!ntrig)) {
    ntrig = 1;
    index = (t_speed < 0) ? lrange : start;
    play = 1;
  } else if (!(inlet_play > 0))
    ntrig = 0;
} else {
  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;
outlet_play = play;
Audio Rate
if (!mode) {
  if (t_speed > 0) {
    if (index >= lrange) {
      index = lstart;
      count += add;
    }
  } else {
    if (index <= lstart) {
      index = lrange;
      count += add;
    }
  }
} else 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