1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef IIRFILT_H 5 #define IIRFILT_H 6 7 #include <stdint.h> 8 9 enum IIR_BIQUARD_TYPE 10 { 11 // pass through 12 IIR_BIQUARD_PASS = 0, 13 // raw filter 14 IIR_BIQUARD_RAW, 15 // low pass filter 16 IIR_BIQUARD_LPF, 17 // high pass filter 18 IIR_BIQUARD_HPF, 19 // band pass filter, constant skirt gain, peak gain = Q 20 IIR_BIQUARD_BPF0, 21 // band pass filter, const 0 dB peak gain 22 IIR_BIQUARD_BPF1, 23 // notch filter 24 IIR_BIQUARD_NOTCH, 25 // allpass filter 26 IIR_BIQUARD_APF, 27 // peakingEQ 28 IIR_BIQUARD_PEAKINGEQ, 29 // low shelf filter 30 IIR_BIQUARD_LOWSHELF, 31 // high shelf filter 32 IIR_BIQUARD_HIGHSHELF, 33 IIR_BIQUARD_QTY 34 }; 35 36 struct IirBiquardState 37 { 38 float a1, a2, b0, b1, b2; 39 float s0, s1, s2; 40 }; 41 42 typedef struct IirBiquardState IirBiquardState; 43 44 void iirfilt_design(IirBiquardState *st, int fs, int f0, float gain, float q, enum IIR_BIQUARD_TYPE type); 45 46 void iirfilt_raw(IirBiquardState *st, float b0, float b1, float b2, float a1, float a2); 47 48 void iirfilt_reset(IirBiquardState *st, int stages); 49 50 void iirfilt_process(IirBiquardState *st, int stages, int16_t *buf, int frame_size); 51 52 void iirfilt_process_int24(IirBiquardState *st, int stages, int32_t *buf, int frame_size); 53 54 void iirfilt_process_float(IirBiquardState *st, int stages, float *buf, int frame_size); 55 56 /* Deal with master gain in iir */ 57 void iirfilt_process2(IirBiquardState *st, int stages, float master_gain, int16_t *buf, int frame_size); 58 59 void iirfilt_process2_int24(IirBiquardState *st, int stages, float master_gain, int32_t *buf, int frame_size); 60 61 void iirfilt_process2_float(IirBiquardState *st, int stages, float master_gain, float *buf, int frame_size); 62 63 void iirfilt_process3(IirBiquardState *st, int stages, float master_gain, int16_t *buf, int frame_size, int stride); 64 65 void iirfilt_process3_int24(IirBiquardState *st, int stages, float master_gain, int32_t *buf, int frame_size, int stride); 66 67 void iirfilt_process3_float(IirBiquardState *st, int stages, float master_gain, float *buf, int frame_size, int stride); 68 69 #endif