triplePeak

3 BP filters in parallel with the original input to make a 3-band parametric resonating EQ C=cutoff R=resonance G=gain
Author: Remco van der Most
License: BSD
Github: sss/filter/triplePeak.axo

Inlets

frac32buffer filter input

frac32 C1

frac32 B1

frac32 G1

frac32 C2

frac32 B2

frac32 G2

frac32 C3

frac32 B3

frac32 G3

Outlets

frac32buffer filter output

Parameters

frac32.s.map.pitch C1

frac32.s.map.pitch C2

frac32.s.map.pitch C3

frac32.u.map.filterq B1

frac32.u.map.filterq B2

frac32.u.map.filterq B3

frac32.s.map G1

frac32.s.map G2

frac32.s.map G3

frac32.s.map gain

Declaration
int32_t low[3];
int32_t band[3];
int32_t OUT[3];
int32_t freq[3];
int32_t Damp[3];
int32_t G[3];
int i;
int32_t config(int32_t pitch, int32_t reso, int32_t Gain, int Inst) {
  int32_t damp = (0x80 << 24) - (reso << 4);
  damp = ___SMMUL(damp, damp);
  Damp[Inst] = damp;
  int32_t alpha;
  MTOFEXTENDED(pitch, alpha);
  SINE2TINTERP(alpha, freq[Inst]);
  G[Inst] = Gain > 0 ? Gain << 2 : Gain;
}

int32_t SVF(int32_t in1, int32_t Freq, int32_t damp, int32_t gain,
            int32_t Inst) {
  int32_t notch = in1 - __SSAT((___SMMUL(damp, band[Inst]) << 1), 29);
  low[Inst] = low[Inst] + __SSAT((___SMMUL(Freq, band[Inst]) << 1), 29);
  int32_t high = notch - low[Inst];
  band[Inst] = (___SMMUL(Freq, high) << 1) + __SSAT(band[Inst], 27);
  OUT[Inst] = ___SMMUL(band[Inst] << 3, gain << 2);
}
Init
for (i = 0; i < 3; i++) {
  low[i] = 0;
  band[i] = 0;
}
Control Rate
config(inlet_C1 + param_C1, __USAT(param_B1 + inlet_B1, 27),
       inlet_G1 + param_G1, 0);
config(inlet_C2 + param_C2, __USAT(param_B2 + inlet_B2, 27),
       inlet_G2 + param_G2, 1);
config(inlet_C3 + param_C3, __USAT(param_B3 + inlet_B3, 27),
       inlet_G3 + param_G3, 2);
Audio Rate
int32_t IN1 = inlet_in1 + ___SMMUL(param_gain << 4, inlet_in1 << 1);
int32_t out;
SVF(IN1, freq[0], Damp[0], G[0], 0);
SVF(IN1, freq[1], Damp[1], G[1], 1);
SVF(IN1, freq[2], Damp[2], G[2], 2);
out = OUT[0] + OUT[1] + OUT[2] + IN1;
outlet_out = out;

Privacy

© 2024 Zrna Research