ldrive_new full

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

Inlets

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

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

frac32.bipolar speed modulation

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

Outlets

frac32.bipolar total speed

bool32 playback state

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

Parameters

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

bool32.tgl 1shot

Attributes

objref table

Declaration
int32_t index;
bool r;
uint8_t shift;

int ntrig;

int32_t t_speed;
int32_t re;
int32_t rs;
int32_t loopstart;
int32_t start;
uint32_t count;
bool add;
bool play;
bool mode;
Init
// set 'shift factor' for storing the recording length/the sync output
shift = (27 - attr_table.LENGTHPOW);
Control Rate
loopstart = ___SMMUL(inlet_range, inlet_loopstart) << 5;
t_speed = ((inlet_speed + param_speed) * (float)(1.0f / (1 << (27 - shift))));
re = (t_speed > 0) ? inlet_range - (1 << shift) : inlet_range;
rs = (t_speed > 0) ? start : start - (1 << shift);
add = inlet_range;

start = ___SMMUL(inlet_range, inlet_startpoint) << 5;
mode = inlet_1shot || param_1shot;

if (mode) {
  if (inlet_play && (!ntrig)) {
    ntrig = 1;
    index = (t_speed < 0) ? inlet_range : start;
    play = 1;
  } else if (!(inlet_play > 0))
    ntrig = 0;
} else {
  play = inlet_play;
  if (inlet_r2start && (!r)) {
    index = start;
    r = 1;
    count = 0;
  }
  if (inlet_r2offset && (!r)) {
    index = 0;
    r = 1;
    count = 0;
  }
  if ((!inlet_r2start) && (!inlet_r2offset))
    r = 0;
}

outlet_count = (inlet_play) ? count : -1;
outlet_spos = ((index >> shift) > 0) ? (index >> 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 >= inlet_range) {
      index = loopstart;
      count += add;
    }
  } else {
    if (index <= loopstart) {
      index = inlet_range;
      count += add;
    }
  }
} else if ((index > re) || (index < rs))
  play = 0;

outlet_pos = __USAT((index + inlet_offset), 27);

if (play)
  index += t_speed;
else
  outlet_pos = 0;

Privacy

© 2024 Zrna Research