ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dsps_biquad_gen.h File Reference
#include "dsp_err.h"
Include dependency graph for dsps_biquad_gen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

esp_err_t dsps_biquad_gen_lpf_f32 (float *coeffs, float f, float qFactor)
 LPF IIR filter coefficients Coefficients for low pass 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform.
esp_err_t dsps_biquad_gen_hpf_f32 (float *coeffs, float f, float qFactor)
 HPF IIR filter coefficients.
esp_err_t dsps_biquad_gen_bpf_f32 (float *coeffs, float f, float qFactor)
 BPF IIR filter coefficients.
esp_err_t dsps_biquad_gen_bpf0db_f32 (float *coeffs, float f, float qFactor)
 0 dB BPF IIR filter coefficients
esp_err_t dsps_biquad_gen_notch_f32 (float *coeffs, float f, float gain, float qFactor)
 Notch IIR filter coefficients.
esp_err_t dsps_biquad_gen_allpass360_f32 (float *coeffs, float f, float qFactor)
 Allpass 360 degree IIR filter coefficients.
esp_err_t dsps_biquad_gen_allpass180_f32 (float *coeffs, float f, float qFactor)
 Allpass 180 degree IIR filter coefficients.
esp_err_t dsps_biquad_gen_peakingEQ_f32 (float *coeffs, float f, float qFactor)
 peak IIR filter coefficients
esp_err_t dsps_biquad_gen_lowShelf_f32 (float *coeffs, float f, float gain, float qFactor)
 low shelf IIR filter coefficients
esp_err_t dsps_biquad_gen_highShelf_f32 (float *coeffs, float f, float gain, float qFactor)
 high shelf IIR filter coefficients

Function Documentation

◆ dsps_biquad_gen_allpass180_f32()

esp_err_t dsps_biquad_gen_allpass180_f32 ( float * coeffs,
float f,
float qFactor )

Allpass 180 degree IIR filter coefficients.

Coefficients for all pass 2nd order IIR filter (bi-quad) with 180 degree phase shift The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 182 of file dsps_biquad_gen_f32.c.

183{
184 if (qFactor <= 0.0001) {
185 qFactor = 0.0001;
186 }
187 float Fs = 1;
188
189 float w0 = 2 * M_PI * f / Fs;
190 float c = cosf(w0);
191 float s = sinf(w0);
192 float alpha = s / (2 * qFactor);
193
194 float b0 = 1 - alpha;
195 float b1 = -2 * c;
196 float b2 = 1 + alpha;
197 float a0 = 1 + alpha;
198 float a1 = -2 * c;
199 float a2 = 1 - alpha;
200
201 coeffs[0] = b0 / a0;
202 coeffs[1] = b1 / a0;
203 coeffs[2] = b2 / a0;
204 coeffs[3] = a1 / a0;
205 coeffs[4] = a2 / a0;
206 return ESP_OK;
207}
#define ESP_OK
Definition esp_err.h:23
#define M_PI
Definition esp_err.h:26
float coeffs[256]
Definition test_fir.c:14

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_allpass360_f32()

esp_err_t dsps_biquad_gen_allpass360_f32 ( float * coeffs,
float f,
float qFactor )

Allpass 360 degree IIR filter coefficients.

Coefficients for all pass 2nd order IIR filter (bi-quad) with 360 degree phase shift The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 155 of file dsps_biquad_gen_f32.c.

156{
157 if (qFactor <= 0.0001) {
158 qFactor = 0.0001;
159 }
160 float Fs = 1;
161
162 float w0 = 2 * M_PI * f / Fs;
163 float c = cosf(w0);
164 float s = sinf(w0);
165 float alpha = s / (2 * qFactor);
166
167 float b0 = 1 - alpha;
168 float b1 = -2 * c;
169 float b2 = 1 + alpha;
170 float a0 = 1 + alpha;
171 float a1 = -2 * c;
172 float a2 = 1 - alpha;
173
174 coeffs[0] = b0 / a0;
175 coeffs[1] = b1 / a0;
176 coeffs[2] = b2 / a0;
177 coeffs[3] = a1 / a0;
178 coeffs[4] = a2 / a0;
179 return ESP_OK;
180}

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_bpf0db_f32()

esp_err_t dsps_biquad_gen_bpf0db_f32 ( float * coeffs,
float f,
float qFactor )

0 dB BPF IIR filter coefficients

Coefficients for band pass 2nd order IIR filter (bi-quad) with 0 dB gain in passband The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter center frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 100 of file dsps_biquad_gen_f32.c.

101{
102 if (qFactor <= 0.0001) {
103 qFactor = 0.0001;
104 }
105 float Fs = 1;
106
107 float w0 = 2 * M_PI * f / Fs;
108 float c = cosf(w0);
109 float s = sinf(w0);
110 float alpha = s / (2 * qFactor);
111
112 float b0 = alpha;
113 float b1 = 0;
114 float b2 = -alpha;
115 float a0 = 1 + alpha;
116 float a1 = -2 * c;
117 float a2 = 1 - alpha;
118
119 coeffs[0] = b0 / a0;
120 coeffs[1] = b1 / a0;
121 coeffs[2] = b2 / a0;
122 coeffs[3] = a1 / a0;
123 coeffs[4] = a2 / a0;
124 return ESP_OK;
125}

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_bpf_f32()

esp_err_t dsps_biquad_gen_bpf_f32 ( float * coeffs,
float f,
float qFactor )

BPF IIR filter coefficients.

Coefficients for band pass 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter center frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 73 of file dsps_biquad_gen_f32.c.

74{
75 if (qFactor <= 0.0001) {
76 qFactor = 0.0001;
77 }
78 float Fs = 1;
79
80 float w0 = 2 * M_PI * f / Fs;
81 float c = cosf(w0);
82 float s = sinf(w0);
83 float alpha = s / (2 * qFactor);
84
85 float b0 = s / 2;
86 float b1 = 0;
87 float b2 = -b0;
88 float a0 = 1 + alpha;
89 float a1 = -2 * c;
90 float a2 = 1 - alpha;
91
92 coeffs[0] = b0 / a0;
93 coeffs[1] = b1 / a0;
94 coeffs[2] = b2 / a0;
95 coeffs[3] = a1 / a0;
96 coeffs[4] = a2 / a0;
97 return ESP_OK;
98}

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_highShelf_f32()

esp_err_t dsps_biquad_gen_highShelf_f32 ( float * coeffs,
float f,
float gain,
float qFactor )

high shelf IIR filter coefficients

Coefficients for high pass Shelf 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
gaingain in stopband in dB
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 264 of file dsps_biquad_gen_f32.c.

265{
266 if (qFactor <= 0.0001) {
267 qFactor = 0.0001;
268 }
269 float Fs = 1;
270
271 float A = sqrtf(pow(10, (double)gain / 20.0));
272 float w0 = 2 * M_PI * f / Fs;
273 float c = cosf(w0);
274 float s = sinf(w0);
275 float alpha = s / (2 * qFactor);
276
277 float b0 = A * ((A + 1) + (A - 1) * c + 2 * sqrtf(A) * alpha);
278 float b1 = -2 * A * ((A - 1) + (A + 1) * c);
279 float b2 = A * ((A + 1) + (A - 1) * c - 2 * sqrtf(A) * alpha);
280 float a0 = (A + 1) - (A - 1) * c + 2 * sqrtf(A) * alpha;
281 float a1 = 2 * ((A - 1) - (A + 1) * c);
282 float a2 = (A + 1) - (A - 1) * c - 2 * sqrtf(A) * alpha;
283
284 coeffs[0] = b0 / a0;
285 coeffs[1] = b1 / a0;
286 coeffs[2] = b2 / a0;
287 coeffs[3] = a1 / a0;
288 coeffs[4] = a2 / a0;
289 return ESP_OK;
290}
float A[4][8]
Definition test_mmult.c:20

References A, coeffs, ESP_OK, and M_PI.

Referenced by audio_process_task(), audio_process_task(), audio_process_task(), buttons_process_task(), buttons_process_task(), and buttons_process_task().

Here is the caller graph for this function:

◆ dsps_biquad_gen_hpf_f32()

esp_err_t dsps_biquad_gen_hpf_f32 ( float * coeffs,
float f,
float qFactor )

HPF IIR filter coefficients.

Coefficients for high pass 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter cut off frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 46 of file dsps_biquad_gen_f32.c.

47{
48 if (qFactor <= 0.0001) {
49 qFactor = 0.0001;
50 }
51 float Fs = 1;
52
53 float w0 = 2 * M_PI * f / Fs;
54 float c = cosf(w0);
55 float s = sinf(w0);
56 float alpha = s / (2 * qFactor);
57
58 float b0 = (1 + c) / 2;
59 float b1 = -(1 + c);
60 float b2 = b0;
61 float a0 = 1 + alpha;
62 float a1 = -2 * c;
63 float a2 = 1 - alpha;
64
65 coeffs[0] = b0 / a0;
66 coeffs[1] = b1 / a0;
67 coeffs[2] = b2 / a0;
68 coeffs[3] = a1 / a0;
69 coeffs[4] = a2 / a0;
70 return ESP_OK;
71}

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_lowShelf_f32()

esp_err_t dsps_biquad_gen_lowShelf_f32 ( float * coeffs,
float f,
float gain,
float qFactor )

low shelf IIR filter coefficients

Coefficients for low pass Shelf 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
gaingain in stopband in dB
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 236 of file dsps_biquad_gen_f32.c.

237{
238 if (qFactor <= 0.0001) {
239 qFactor = 0.0001;
240 }
241 float Fs = 1;
242
243 float A = sqrtf(pow(10, (double)gain / 20.0));
244 float w0 = 2 * M_PI * f / Fs;
245 float c = cosf(w0);
246 float s = sinf(w0);
247 float alpha = s / (2 * qFactor);
248
249 float b0 = A * ((A + 1) - (A - 1) * c + 2 * sqrtf(A) * alpha);
250 float b1 = 2 * A * ((A - 1) - (A + 1) * c);
251 float b2 = A * ((A + 1) - (A - 1) * c - 2 * sqrtf(A) * alpha);
252 float a0 = (A + 1) + (A - 1) * c + 2 * sqrtf(A) * alpha;
253 float a1 = -2 * ((A - 1) + (A + 1) * c);
254 float a2 = (A + 1) + (A - 1) * c - 2 * sqrtf(A) * alpha;
255
256 coeffs[0] = b0 / a0;
257 coeffs[1] = b1 / a0;
258 coeffs[2] = b2 / a0;
259 coeffs[3] = a1 / a0;
260 coeffs[4] = a2 / a0;
261 return ESP_OK;
262}

References A, coeffs, ESP_OK, and M_PI.

Referenced by audio_process_task(), audio_process_task(), audio_process_task(), buttons_process_task(), buttons_process_task(), and buttons_process_task().

Here is the caller graph for this function:

◆ dsps_biquad_gen_lpf_f32()

esp_err_t dsps_biquad_gen_lpf_f32 ( float * coeffs,
float f,
float qFactor )

LPF IIR filter coefficients Coefficients for low pass 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform.

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter cut off frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 19 of file dsps_biquad_gen_f32.c.

20{
21 if (qFactor <= 0.0001) {
22 qFactor = 0.0001;
23 }
24 float Fs = 1;
25
26 float w0 = 2 * M_PI * f / Fs;
27 float c = cosf(w0);
28 float s = sinf(w0);
29 float alpha = s / (2 * qFactor);
30
31 float b0 = (1 - c) / 2;
32 float b1 = 1 - c;
33 float b2 = b0;
34 float a0 = 1 + alpha;
35 float a1 = -2 * c;
36 float a2 = 1 - alpha;
37
38 coeffs[0] = b0 / a0;
39 coeffs[1] = b1 / a0;
40 coeffs[2] = b2 / a0;
41 coeffs[3] = a1 / a0;
42 coeffs[4] = a2 / a0;
43 return ESP_OK;
44}

References coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_notch_f32()

esp_err_t dsps_biquad_gen_notch_f32 ( float * coeffs,
float f,
float gain,
float qFactor )

Notch IIR filter coefficients.

Coefficients for notch 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
gaingain in stopband in dB
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 127 of file dsps_biquad_gen_f32.c.

128{
129 if (qFactor <= 0.0001) {
130 qFactor = 0.0001;
131 }
132 float Fs = 1;
133
134 float A = sqrtf(pow(10, (double)gain / 20.0));
135 float w0 = 2 * M_PI * f / Fs;
136 float c = cosf(w0);
137 float s = sinf(w0);
138 float alpha = s / (2 * qFactor);
139
140 float b0 = 1 + alpha * A;
141 float b1 = -2 * c;
142 float b2 = 1 - alpha * A;
143 float a0 = 1 + alpha;
144 float a1 = -2 * c;
145 float a2 = 1 - alpha;
146
147 coeffs[0] = b0 / a0;
148 coeffs[1] = b1 / a0;
149 coeffs[2] = b2 / a0;
150 coeffs[3] = a1 / a0;
151 coeffs[4] = a2 / a0;
152 return ESP_OK;
153}

References A, coeffs, ESP_OK, and M_PI.

◆ dsps_biquad_gen_peakingEQ_f32()

esp_err_t dsps_biquad_gen_peakingEQ_f32 ( float * coeffs,
float f,
float qFactor )

peak IIR filter coefficients

Coefficients for peak 2nd order IIR filter (bi-quad) The implementation use ANSI C and could be compiled and run on any platform

Parameters
coeffsresult coefficients. b0,b1,b2,a1,a2, a0 are not placed to the array and expected by IIR as 1
ffilter notch frequency in range of 0..0.5 (normalized to sample frequency)
qFactorQ factor of filter
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 209 of file dsps_biquad_gen_f32.c.

210{
211 if (qFactor <= 0.0001) {
212 qFactor = 0.0001;
213 }
214 float Fs = 1;
215
216 float w0 = 2 * M_PI * f / Fs;
217 float c = cosf(w0);
218 float s = sinf(w0);
219 float alpha = s / (2 * qFactor);
220
221 float b0 = alpha;
222 float b1 = 0;
223 float b2 = -alpha;
224 float a0 = 1 + alpha;
225 float a1 = -2 * c;
226 float a2 = 1 - alpha;
227
228 coeffs[0] = b0 / a0;
229 coeffs[1] = b1 / a0;
230 coeffs[2] = b2 / a0;
231 coeffs[3] = a1 / a0;
232 coeffs[4] = a2 / a0;
233 return ESP_OK;
234}

References coeffs, ESP_OK, and M_PI.