ldrive test2

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

bool32.rising r2zero

bool32.rising reset to startpoint

Outlets

frac32buffer.positive drive table/read

int32 loop count since reset

int32 lenght of the loop in samples

int32 slength

Parameters

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

Attributes

objref table

Declaration
float32_t index;

bool r;
bool rzero;

uint32_t pos;

uint8_t shift;
uint32_t range;
uint32_t t_speed;
uint32_t loopstart;
uint32_t reset;
uint32_t count;
bool add;
Init
index = 0;
r = 1;

// set 'shift factor' for storing the recording length/the sync output
shift = (27 - attr_table.LENGTHPOW);
Control Rate
range = (inlet_range >> shift);
loopstart = (___SMMUL(range, inlet_loopstart) << 5);
t_speed = (inlet_speed + param_speed);

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

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

if (inlet_r2zero && rzero) {
  index = 0;
  rzero = 0;
  count = 0;
} else if (!inlet_r2zero)
  rzero = 1;

outlet_count = count;
outlet_spos = pos;
outlet_slength = range - loopstart;
Audio Rate
index += (t_speed * (float)(1.0f / (1 << 27)));
pos = (index + loopstart);
add = range;

// set a range

if (t_speed > 0) {
  if (pos >= range) {
    index = 0;
    count += add;
  }
} else {
  if (pos <= loopstart) {
    index = (range - loopstart);
    count += add;
  }
}

if (inlet_play)
  outlet_pos = ((pos << shift) + inlet_offset);
else
  outlet_pos = 0;

Privacy

© 2024 Zrna Research