ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
test_iir_biquad.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <math.h>
5
6#include "dsp_common.h"
7
8#include "dsps_biquad.h"
9
10#define N_SAMPLES 1024
12// Input test array
13float d[N_SAMPLES];
14// output array
15float y[N_SAMPLES];
17
20esp_err_t dsps_biquad_f32_aes3(const float *input, float *output, int len, float *coef, float *w);
21
23{
24 float coeffs_lpf[5] = {0.073802, 0.147603, 0.073802, -1.250516, 0.545723};
25 float w_lpf[5] = {0, 0};
26 float w_lpf_ref[5] = {0, 0};
27 esp_err_t ret = ESP_OK;
28
29 for (size_t i = 0; i < N; i++) {
30 d[i] = 0;
31 }
32 d[0] = 1;
34 ret = dsps_biquad_f32_ansi(d, y_ref, N, coeffs_lpf, w_lpf_ref);
36 if (ret != ESP_OK) {
37 printf("dsps_biquad_f32 error = %i\n", ret);
38 return;
39 }
41 ret = dsps_biquad_f32_aes3(d, y, N, coeffs_lpf, w_lpf);
43 if (ret != ESP_OK) {
44 printf("dsps_biquad_f32 error = %i\n", ret);
45 return;
46 }
47 for (size_t i = 0; i < N; i++) {
48 if (((y[i] - y_ref[i]) > 0.0000001) || (y[i] - y_ref[i]) < -0.0000001) {
49 printf("ERROR result[%i]: %f, expect = %f, diff=%f\n", i, y[i], y_ref[i], y[i] - y_ref[i]);
50 return;
51
52 }
53 }
54 printf("Test Correct!\n");
55
56}
esp_err_t dsps_biquad_f32_ansi(const float *input, float *output, int len, float *coef, float *w)
IIR filter.
int esp_err_t
Definition esp_err.h:21
#define ESP_OK
Definition esp_err.h:23
float y[1024]
Definition test_fir.c:11
void xt_iss_profile_disable()
float d[1024]
float y_ref[1024]
esp_err_t dsps_biquad_f32_aes3(const float *input, float *output, int len, float *coef, float *w)
#define N_SAMPLES
void test_iir_biquad()
void xt_iss_profile_enable()
#define N
Definition test_mmult.c:13