invMod

This module creates a buffer, inversely reads this buffer and combines this with the incoming signal by ringmodulation or addition. Mix with original signal to fatten the sound of an oscillator. Big buffers create a sort of delay, though not in the "normal sense".
Author: Remco van der Most
License: BSD
Github: sss/delay/invMod.axo

Inlets

frac32buffer wave input

frac32 pitch

Outlets

frac32buffer out

Parameters

frac32.s.map.pitch length of inversed reading buffer (window)

frac32.s.map offset from writeposition (delay)

bool32.tgl ringmodulation or addition of audio input with inversed reading buffer

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;
uint32_t readpos;
Init
static int16_t _array[attr_poly][1 << attr_size]
    __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
int i;
writepos = 0;
readpos = 0;
for (i = 0; i < LENGTH; i++)
  array[i] = 0;
Control Rate
int32_t length; //=___SMMUL(LENGTH<<1,param_length);
MTOF(-param_pitch - inlet_pitch, length)
length = length >> 27 - LENGTHPOW;
int32_t ofs;
MTOF(-param_ofs - inlet_pitch, ofs)
ofs = ofs >> 27 - LENGTHPOW;
Audio Rate
writepos = (writepos + 1) & LENGTHMASK;
readpos = (readpos + 2);
// writepos-=writepos>=length?length:0;
readpos -= readpos >= length ? length : 0;
array[writepos & LENGTHMASK] = __SSAT(inlet_in >> 14, 16);
switch (param_mode) {
case 0:
  outlet_out = ___SMMUL(array[(writepos - readpos - ofs) & LENGTHMASK] << 17,
                        inlet_in << 3);
  break;
case 1:
  outlet_out =
      (array[(writepos - readpos - ofs) & LENGTHMASK] << 14) + inlet_in >> 1;
  break;
}

Privacy

© 2024 Zrna Research