tappedDelay2

multi-tap delay with lowpass filter on each tap. You enter the tap-velocity/timing/cutoff for each tap by external tapping. eg. when using a midi note module: connect gate-output of midi module to the tap-input of this module connect note-output of midi module to the cutoft-input of this module connect velocity-output of midi module to the vel-input of this module first tap you play will reset the timing-counter to the "zero" position->incoming note taps after this will set the timing/velocity/cutoff of the delays. when you want to set new timings for the delay, just hit "rst" and play a new rhythm. on-module cutoff-knob is added to the recorded cutoff.
Author: Remco van der Most
License: BSD
Github: sss/delay/tappedDelay2.axo

Inlets

frac32 cutoff

frac32 vel

frac32 feed

int32 BPM

frac32buffer wave input

bool32 rst

bool32 tap

bool32 sync

Outlets

frac32buffer out

Parameters

frac32.s.map.pitch lp

frac32.s.map.pitch hp

frac32.s.map feed

frac32.s.map res

int32 max

bool32.mom rst

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);
int16_t *array;
uint32_t writepos;
int delays;
int Dels;
int32_t times[16];
int32_t velocity[16];
int32_t f[16];
int32_t g[16];
int32_t h[16];
int32_t val[16];
int32_t vol[16];
int gtrig;
int rtrig;
uint32_t count = 0;
int start;
int i;
int32_t out;
int trig;
uint32_t Count;
uint32_t Time;
int BPM;
Init
static int16_t _array[1 << attr_size] __attribute__((section(".sdram")));
array = &_array[0];
writepos = 0;
for (i = 0; i < LENGTH; i++)
  array[i] = 0;
delays = 0;
start = 1;
Count = 1 << 31;
Time = 1 << 31;
Control Rate
int rst = inlet_rst + param_rst;

int32_t MAX = LENGTH / Time * Time;

if ((rst > 0) && !rtrig) {
  delays = 0;
  Dels = 0;
  start = 1;
  rtrig = 1;
  BPM = inlet_BPM;
  count = 0;
} else if (rst == 0) {
  rtrig = 0;
}

float32_t ratio;
ratio = (float32_t)BPM / inlet_BPM;

if ((inlet_tap > 0) && !gtrig) {
  if (start == 1) {
    count = 0;
    start = 0;
  }
  if (delays > 0) {
    times[Dels] = count;
    g[Dels] = inlet_cutoff;
    velocity[Dels] = inlet_vel << 2;
  }
  Dels += 1;
  Dels = Dels > param_max ? 0 : Dels;
  delays = Dels > delays ? Dels : delays;
  gtrig = 1;
} else if (inlet_tap == 0) {
  gtrig = 0;
}
int32_t feed = __SSAT(param_feed + inlet_feed, 27);
if (delays > 0) {
  for (i = 0; i < (delays - 1); i++) {
    MTOF(g[i] + param_lp, f[i])
    MTOF(g[i] + param_hp, h[i])
  }
}
Audio Rate
Count += 1;
if ((inlet_sync > 0) && !trig) {
  trig = 1;
  Time = Count;
  Count = 0;
} else if (inlet_sync == 0) {
  trig = 0;
}

writepos = (writepos + 1) & LENGTHMASK;
array[writepos] = __SSAT((inlet_in + ___SMMUL(feed << 2, out << 2)) >> 16, 16);
count += 1;
count = count - count / MAX * MAX;
out = 0;
int32_t tmp;
if (delays > 0) {
  for (i = 0; i < (delays - 1); i++) {
    tmp = ___SMMUL(array[(writepos - (int32_t)(times[i] * ratio)) & LENGTHMASK]
                       << 19,
                   velocity[i]) -
          ___SMMUL(param_res << 3, val[i] - vol[i] << 2);
    val[i] = ___SMMLA((tmp - val[i]) << 1, f[i], val[i]);
    vol[i] = ___SMMLA((val[i] - vol[i]) << 1, h[i], vol[i]);
    out += val[i] - vol[i];
  }
}
outlet_out = out + inlet_in;

Privacy

© 2024 Zrna Research