cphaser

single stage phaser module to use with the chainFX effects chainer module. Controls can easily be editted for external control
Author: Remco van der Most
License: BSD
Github: sss/fx/chainer/cphaser.axo

Inlets

None

Outlets

None

Parameters

frac32.s.map rate

frac32.s.map feed

bool32.tgl dir

bool32.tgl bypass

bool32.tgl solo

frac32.u.map time

frac32.u.map depth

Declaration
static const uint32_t LENGTHPOW = (11);
static const uint32_t LENGTH = (1 << 11);
static const uint32_t LENGTHMASK = ((1 << 11) - 1);
int16_t *array;
uint32_t writepos;
uint32_t v31 = (uint32_t)1 << 31;
uint32_t v30 = (uint32_t)1 << 30;
int32_t outL;
int32_t outR;
uint32_t phs;
int32_t rate;
bool dir;
int32_t depth;
int32_t TM;
int32_t F1;
int32_t F2;
int32_t FD;

bool solo, bypass;
int32_t FX(int32_t inL, int32_t inR, int32_t CV1, int32_t CV2) {
  int32_t IL = inL;
  int32_t IR = inR;
  inL += F1;
  inR += F2;
  writepos = (writepos + 1) & LENGTHMASK;
  array[writepos] = __SSAT(inL >> 14, 16);
  array[writepos + LENGTH] = __SSAT(inR >> 14, 16);
  phs += (dir > 0 ? -rate : rate) + (___SMMUL(rate, CV1) << 8);
  int32_t tm;
  int32_t r1;
  int32_t r2;
  uint32_t PHS = phs + (CV2 << 5);
  uint32_t P2;
  HANNING2TINTERP(PHS, r1)
  P2 = (uint32_t)PHS + v30;
  HANNING2TINTERP(P2, r2)

  MTOF(-TM - ___SMMUL(PHS >> 1, depth), tm)
  tm = tm >> 16;
  outL = ___SMMUL((array[(writepos - tm) & LENGTHMASK] << 15), r1);
  MTOF(-TM - ___SMMUL(P2 >> 1, depth), tm)
  tm = tm >> 16;
  outR = ___SMMUL((array[((writepos - tm) & LENGTHMASK) + LENGTH] << 15), r2);

  uint32_t P1 = (uint32_t)PHS + v31;
  HANNING2TINTERP(P1, r1)
  P2 = P1 + v30;
  HANNING2TINTERP(P2, r2)
  MTOF(-TM - ___SMMUL(P1 >> 1, depth), tm)
  tm = tm >> 16;
  outL += ___SMMUL((array[(writepos - tm) & LENGTHMASK] << 15), r1);
  MTOF(-TM - ___SMMUL(P2 >> 1, depth), tm)
  tm = tm >> 16;
  outR += ___SMMUL((array[((writepos - tm) & LENGTHMASK) + LENGTH] << 15), r2);
  F1 = ___SMMUL(FD, outL) << 1;
  F2 = ___SMMUL(FD, outR) << 1;
  outL = (IL + F1);
  outR = (IR + F2);
  if (bypass > 0) {
    outL = IL;
    outR = IR;
  }
};
Init
static int16_t _array[LENGTH * 2] __attribute__((section(".sdram")));
array = &_array[0];
int i;
writepos = 0;
for (i = 0; i < LENGTH * 2; i++)
  array[i] = 0;
Control Rate
MTOFEXTENDED(param_rate, rate)
rate = rate >> 10;
dir = param_dir;
depth = param_depth << 2;
TM = param_time;
FD = param_feed << 4;
bypass = param_bypass;
solo = param_solo;

Privacy

© 2024 Zrna Research