repeater

audio repeater module. Can be used in-line in your audio-chain and doesn't need an external delay write module. When input "on" is low, audio input is just send thru to the output. when input "on" goes high, starts repeating the last audio that came in. repeating size is set by the "size" inlet. NOTE! size is set in samples! Use my clock2timing module to get the sample length to fit host tempo and connect the size input through a "ratioVCAI" module (math folder) to the "ksamples" output on the "clock2timing" module. The "ratioVCAI" can then be used to set any desirable ratio to the host tempo the repeat input sets the amount of times the buffer is repeated as long as the "on" input is high. After that, a new sample is taken which itself will be repeated the set amount of times before another sample is taken again. Bit of a drawback of the way the module is coded, is that there is no pitch-control possible. Use the "grainer" module if you want pitch-control
Author: Remco van der Most
License: BSD
Github: sss/delay/repeater.axo

Inlets

bool32 on

bool32 reverse

int32 connect to "Ksamples" on my clock2timing module. Use ratioVCAI to set ratio to host tempo

int32 repeat

frac32 Ksize

frac32buffer in

Outlets

frac32buffer out

bool32 rec

Parameters

frac32.u.map size

int32 repeat

bool32.tgl duck

Attributes

combo size

Declaration
static const uint32_t LENGTHPOW = (attr_size);
static const uint32_t LENGTH = (1 << attr_size);
static const uint32_t LENGTHMASK = ((1 << attr_size) - 1);
int32_t *array;
uint32_t writepos;
uint32_t phase;
int32_t size;
int32_t times;
int32_t rec;
int32_t out;
int32_t aut;
int32_t window;
int32_t val;
int ttrig;
int32_t on;
int32_t repeat;
int32_t ON;
Init
static int32_t _array[attr_poly][1 << attr_size]
    __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
int i;
writepos = 0;
for (i = 0; i < LENGTH; i++)
  array[i] = 0;
Control Rate
size = param_size;
size = ___SMMUL(size << 3, size << 2);
size = ___SMMUL(__USAT(size + inlet_Ksize, 27) << 3, LENGTH << 2) + inlet_size;
repeat = inlet_repeat + param_repeat;
outlet_rec = rec;
Audio Rate
//(on>0?on-rec:on)
ON += (((on > 0 ? on - (rec << 27) : on) - ON) >> 5);

if ((inlet_in > 0) && (!(ttrig))) {
  ttrig = 1;
  on = inlet_on > 0 ? (1 << 27) : 0;
} else if (inlet_in < 0) {
  ttrig = 0;
}

out = ___SMMUL(((1 << 27) - ON * (param_duck)) << 3, inlet_in << 2);

if ((!(on > 0)) || (rec > 0)) {
  writepos = (writepos + 1) & LENGTHMASK;
  array[writepos] = __SSAT(out, 28);
}

if (!(inlet_on > 0)) {
  times = 0;
  phase = 0;
}

if (on > 0) {
  phase += 1;
  phase = phase - ((phase / size) * size);
  times = phase == 0 ? times + 1 : times;
  times = times - ((times / repeat) * repeat);
  rec = times >= (repeat - 1) ? 1 : 0;
}

aut = array[(writepos + (inlet_reverse > 0 ? -phase : phase - size)) &
            LENGTHMASK];
// aut+=array[(writepos-phase)&LENGTHMASK]>>1;
outlet_out = out + ___SMMUL(ON << 3, aut << 2);

Privacy

© 2024 Zrna Research