multimodeiBiq

2-pole resonant multimode filter (biquad) 0=lowpass 1=highpass 2=bandpass 3=notch (in-bandpass) 4=parametric(in+bandpass) 5=lowshelf(lowpass+in*gain) 6=highshelf(highpass+in*gain) 7="allpass"(lowpass-highpass) 8=lowpass+bandpass 9=highpass_bandpass
Author: Johannes Taelman
License: BSD
Github: sss/filter/multimodeiBiq.axo

Inlets

frac32buffer filter input

frac32 pitch

frac32 filter resonance

Outlets

frac32buffer filter output

Parameters

frac32.s.map.pitch pitch

frac32.u.map.filterq reso

frac32.s.map gain

int32.hradio mode

Declaration
biquad_state bs;
biquad_coefficients bc;
biquad_state Bs;
biquad_coefficients Bc;
int32_t freq;
int i;
int32_t out[BUFSIZE];
int32_t filter(int32_t FREQ, int32_t RESO, int32_t MODE) {
  switch (MODE > 0 ? MODE : 0) {
  case 0:
    biquad_lp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 1:
    biquad_hp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 2:
    biquad_bp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 3:
    biquad_bp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 4:
    biquad_bp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 5:
    biquad_lp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 6:
    biquad_hp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 7:
    biquad_lp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 8:
    biquad_lp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  case 9:
    biquad_hp_coefs(&bc, FREQ, INT_MAX - (__USAT(RESO, 27) << 4));
    break;
  }
};
Init
biquad_clearstate(&bs);
biquad_clearstate(&Bs);
Control Rate
int32_t mode = param_mode;
int32_t gain = param_gain;
int32_t reso = inlet_reso + param_reso;
MTOF(param_pitch + inlet_pitch, freq);
filter(freq, reso, mode);
biquad_dsp(&bs, &bc, inlet_in, outlet_out);

switch (mode > 0 ? mode : 0) {

case 0:;
  break;
case 1:;
  break;
case 2:;
  break;

case 3:
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] -= inlet_in[i];
  };
  break;

case 4:
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] = inlet_in[i] + ___SMMUL(outlet_out[i] << 2, gain << 3);
  };
  break;

case 5:
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] = inlet_in[i] + ___SMMUL(outlet_out[i] << 2, gain << 3);
  };
  break;

case 6:
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] = inlet_in[i] + ___SMMUL(outlet_out[i] << 2, gain << 3);
  };
  break;

case 7:
  for (i = 0; i < BUFSIZE; i++) {
    out[i] = outlet_out[i];
  }
  biquad_hp_coefs(&Bc, freq, INT_MAX - (__USAT(reso, 27) << 4));
  biquad_dsp(&Bs, &Bc, inlet_in, outlet_out);
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] -= out[i];
  };
  break;

case 8:
  for (i = 0; i < BUFSIZE; i++) {
    out[i] = outlet_out[i];
  }
  biquad_bp_coefs(&Bc, freq, INT_MAX - (__USAT(reso, 27) << 4));
  biquad_dsp(&Bs, &Bc, inlet_in, outlet_out);
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] -= out[i] + ___SMMUL(param_gain << 3, inlet_in[i] << 2);
  };
  break;
case 9:
  for (i = 0; i < BUFSIZE; i++) {
    out[i] = outlet_out[i];
  }
  biquad_bp_coefs(&Bc, freq, INT_MAX - (__USAT(reso, 27) << 4));
  biquad_dsp(&Bs, &Bc, inlet_in, outlet_out);
  for (i = 0; i < BUFSIZE; i++) {
    outlet_out[i] -= out[i] + ___SMMUL(param_gain << 3, inlet_in[i] << 2);
  };
  break;
}

Privacy

© 2024 Zrna Research