triggered buffer

A circular sample buffer referencing a 32b table. Each time trigger input rises above zero a new sample is taken from in and the oldest sample from the buffer is on out. Good for building pitch shifting tape delays.
Author: Peter Witzel
License: CC0
Github: cpwitz/delay/triggered buffer.axo

IO Variants: 2


Variant: 1

Inlets

frac32buffer audio input

frac32buffer triggered on rising above 0

Outlets

frac32buffer oldest sample output

Attributes

objref table

Declaration
uint32_t pos;
int32_t last_input;
int32_t val_out;
int32_t val_target;
int32_t accu;
int32_t sampleno;
Init
last_input = 0;
pos = 0;
val_out = 0;
val_target = 0;
accu = 0;
sampleno = 0;
Audio Rate
if (inlet_trigger > 0 && last_input <= 0) {
  pos = (pos + 1) & attr_table.LENGTHMASK;
  val_target = attr_table.array[(pos + 1) & attr_table.LENGTHMASK];
  attr_table.array[pos] = __SSAT(accu / sampleno, 28);
  accu = 0;
  sampleno = 0;
}
last_input = inlet_trigger;
accu += inlet_in;
sampleno++;
val_out = (val_out + val_out + val_out + val_target) >> 2;
outlet_out = val_out;

Variant: 2

Inlets

frac32.positive feedback mod

frac32buffer audio input

frac32buffer triggered on rising above 0

Outlets

frac32buffer oldest sample output

Parameters

frac32.u.map feedback

Attributes

objref table

Declaration
uint32_t pos;
int32_t last_input;
int32_t val_out;
int32_t val_target;
int32_t accu;
int32_t sampleno;
int32_t fdb_level;
Init
last_input = 0;
pos = 0;
val_out = 0;
val_target = 0;
accu = 0;
sampleno = 0;
fdb_level = 0;
Control Rate
fdb_level = __SSAT((param_feedback + inlet_feedback), 28);
Audio Rate
if (inlet_trigger > 0 && last_input <= 0) {
  pos = (pos + 1) & attr_table.LENGTHMASK;
  val_target = attr_table.array[(pos + 1) & attr_table.LENGTHMASK];
  int32_t val = attr_table.array[pos];
  attr_table.array[pos] =
      __SSAT(accu / sampleno + (___SMMUL(fdb_level, val) << 5), 28);
  accu = 0;
  sampleno = 0;
}
last_input = inlet_trigger;
accu += inlet_in;
sampleno++;
val_out = (val_out + val_out + val_out + val_target) >> 2;
outlet_out = val_out;

Privacy

© 2024 Zrna Research