ldrive nointerp

drives a phasor (saw-wave) for reading/writing data
Author: robert schirmer
License: BSD
Github: rbrt/testing/ldrive nointerp.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

bool32 direction

bool32 play

bool32.rising r2zero

bool32.rising reset to startpoint

Outlets

int32 loop count since reset

int32 playhead position inside loop in samples

int32 length of range in samples

int32 length of loop in samples

frac32buffer audio out

frac32buffer plaback phase in fraction of table

Parameters

int32.hradio direction

Attributes

objref table

Declaration
int32_t index1;
int32_t index2;
int32_t index3;

bool r;
uint8_t shift;

int32_t dir;
int32_t loopstart;
int32_t reset;
uint32_t count;
bool add;

uint32_t offset;
Init
// set 'shift factor' for storing the recording length/the sync output
shift = (27 - attr_table.LENGTHPOW);
Control Rate
offset = ___SMMUL(inlet_offset, (attr_table.LENGTH << 5));
loopstart = ___SMMUL(inlet_range, inlet_loopstart) << 5;
dir = ((((!(inlet_direction || param_direction)) << 1) - 1) << 27) >>
      attr_table.LENGTHPOW;
add = inlet_range;

reset = (___SMMUL(inlet_range, inlet_startpoint) << 5);

if (inlet_r2start && (!r)) {
  index1 = reset;
  r = 1;
  count = 0;
}

if (inlet_r2zero && (!r)) {
  index1 = 0;
  r = 1;
  count = 0;
}
if ((!inlet_r2start) && (!inlet_r2zero))
  r = 0;

outlet_count = count;
outlet_spos = index1 >> shift;
outlet_stotal = inlet_range >> shift;
outlet_sloop = (inlet_range - loopstart) >> shift;
Audio Rate
if (dir > 0) {
  if (index1 >= inlet_range) {
    index1 = loopstart;
    count += add;
  }
} else {
  if (index1 <= loopstart) {
    index1 = inlet_range;
    count += add;
  }
}

outlet_phase = __USAT(index1 + inlet_offset, 27);

outlet_wave = attr_table.array[outlet_phase >> shift] << attr_table.GAIN;

if (inlet_play)
  index1 += dir;
else
  outlet_wave = 0;

Privacy

© 2024 Zrna Research