ZDF HP

Author: Smashed Transistors
License: LGPL
Github: tiar/filter/ZDF HP.axo

Inlets

frac32 pitch

frac32 filter resonance

frac32buffer filter input

Outlets

frac32buffer filter output

frac32buffer lp12

frac32buffer bp6

Parameters

frac32.s.map.pitch pitch

frac32.u.map Q

Declaration
int32_t u, v, av;
int32_t A, B, C, D, E, F;
int32_t x;
Init
u = v = A = B = C = D = E = F = x = av = 0;
Control Rate
float Q = __USAT(param_Q + inlet_reso, 27) * (15.0f / (1 << 27));
Q = 2.0f - 1.0f / (0.1f * Q * Q + 0.5f) + 0.000015f * Q * Q * Q;

uint32_t alpha;
MTOFEXTENDED(param_pitch + inlet_pitch - (545 << 14), alpha);
float Freq = arm::q_to_float(alpha, 32);
Freq *= (1.0f / 32);

float b = 1 + Freq * (Q - 1);
float c = Freq * Q;
float e = -Freq;
for (int i = 0; i < 8; i++) {
  float ce = c * e;
  float bf = b + b - c;
  c = c * bf;
  e = e * bf;
  b = b * b + ce;
}
float a = 1 - b;
float d = -e;
float f = b - c;

for (int i = 0; i < BUFSIZE; i++) {

  x = inlet_x[i];
  u = (__SSAT(u, 30) + __SSAT(u, 28)) >> 1;
  v = (__SSAT(v, 30) + __SSAT(v, 28)) >> 1;
  int32_t nu = ___SMMLA(A, x, ___SMMLA(B, u, ___SMMUL(C, v))) << 5;
  v = ___SMMLA(D, x, ___SMMLA(E, u, ___SMMUL(F, v))) << 5;
  u = nu;

  outlet_lp12[i] = u;
  outlet_bp6[i] = v;
  outlet_hp12[i] = x - u - v;

  if ((av <= 0) && (v >= 0)) {
    A = arm::float_to_q(a, 27);
    B = arm::float_to_q(b, 27);
    C = arm::float_to_q(c, 27);
    D = arm::float_to_q(d, 27);
    E = arm::float_to_q(e, 27);
    F = arm::float_to_q(f, 27);
  }
  av = v;
}

Privacy

© 2024 Zrna Research