bridge

delay coupling operator
Author: Smashed Transistors
License: LGPL
Github: tiar/delay/bridge.axo

Inlets

frac32.bipolar theta

frac32.bipolar LPA

frac32.bipolar attenA

frac32.bipolar LPB

frac32.bipolar attenB

Outlets

None

Parameters

int32 posA

int32 posB

frac32.u.map theta

frac32.u.map LPA

frac32.u.map attenA

frac32.u.map LPB

frac32.u.map attenB

Attributes

objref delayNameA

objref delayNameB

combo invA

combo invB

Declaration
void sinCos_q27(uint32_t theta, int32_t &c, int32_t &s) {
  int32_t a = (theta & ((1 << 20) - 1)) << 8; // q28
  uint32_t i = theta >> 20;
  s = ___SMMLA(a, sine2t[i + 1] - sine2t[i], sine2t[i] >> 4);
  i = (i + 1024) & 4095;
  c = ___SMMLA(a, sine2t[i + 1] - sine2t[i], sine2t[i] >> 4);
}

int32_t lpA, lpB;
Init
lpA = lpB = 0;
Control Rate
int32_t coefA = __USAT((1 << 27) - param_attenA - inlet_attenA, 27) >>
                (27 - 14);
coefA = attr_invA ? coefA : -coefA;

int32_t coefB = __USAT((1 << 27) - param_attenB - inlet_attenB, 27) >>
                (27 - 14);
coefB = attr_invB ? coefB : -coefB;

int32_t c, s;
{
  uint32_t theta = ((param_theta + inlet_theta) & 0x07FFFFFF) << 5;
  sinCos_q27(theta, c, s);
}
int32_t cLPA;
MTOFEXTENDED(param_LPA + inlet_LPA, cLPA);
cLPA = __USAT(cLPA, 30);
int32_t cLPB;
MTOFEXTENDED(param_LPB + inlet_LPB, cLPB);
cLPB = __USAT(cLPB, 30);

// note: read/write indexes are set BUFSIZE samples back as we will process a
// batch of BUFSIZE samples so beware of overlappings when param_delays differ
// by less than 16 samples
int32_t a_rw = (attr_delayNameA.writepos - (BUFSIZE - 1) - param_posA) &
               attr_delayNameA.LENGTHMASK;
int32_t b_rw = (attr_delayNameB.writepos - (BUFSIZE - 1) - param_posB) &
               attr_delayNameB.LENGTHMASK;

// _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
for (int i = 0; i < BUFSIZE; i++) {
  //                              q15              q14    q29   q29     q27
  lpA = ___SMMLA((attr_delayNameA.array[a_rw] * coefA - lpA), cLPA, lpA >> 2)
        << 2;
  lpB = ___SMMLA((attr_delayNameB.array[b_rw] * coefB - lpB), cLPB, lpB >> 2)
        << 2;
  //                                      q24   q29 q27 24-15
  attr_delayNameA.array[a_rw] =
      __SSAT(___SMMLS(lpB, s, ___SMMUL(lpA, c)) >> (24 - 15), 16);
  a_rw = (a_rw + 1) & attr_delayNameA.LENGTHMASK;
  attr_delayNameB.array[b_rw] =
      __SSAT(___SMMLA(lpB, c, ___SMMUL(lpA, s)) >> (24 - 15), 16);
  b_rw = (b_rw + 1) & attr_delayNameB.LENGTHMASK;
}

Privacy

© 2024 Zrna Research