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
11
int
N
=
N_SAMPLES
;
12
// Input test array
13
float
d
[
N_SAMPLES
];
14
// output array
15
float
y
[
N_SAMPLES
];
16
float
y_ref
[
N_SAMPLES
];
17
18
extern
void
xt_iss_profile_disable
();
19
extern
void
xt_iss_profile_enable
();
20
esp_err_t
dsps_biquad_f32_aes3
(
const
float
*input,
float
*output,
int
len,
float
*coef,
float
*w);
21
22
void
test_iir_biquad
()
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;
33
xt_iss_profile_enable
();
34
ret =
dsps_biquad_f32_ansi
(
d
,
y_ref
,
N
, coeffs_lpf, w_lpf_ref);
35
xt_iss_profile_disable
();
36
if
(ret !=
ESP_OK
) {
37
printf(
"dsps_biquad_f32 error = %i\n"
, ret);
38
return
;
39
}
40
xt_iss_profile_enable
();
41
ret =
dsps_biquad_f32_aes3
(
d
,
y
,
N
, coeffs_lpf, w_lpf);
42
xt_iss_profile_disable
();
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
}
dsp_common.h
dsps_biquad.h
dsps_biquad_f32_ansi
esp_err_t dsps_biquad_f32_ansi(const float *input, float *output, int len, float *coef, float *w)
IIR filter.
Definition
dsps_biquad_f32_ansi.c:19
esp_err_t
int esp_err_t
Definition
esp_err.h:21
ESP_OK
#define ESP_OK
Definition
esp_err.h:23
y
float y[1024]
Definition
test_fir.c:11
xt_iss_profile_disable
void xt_iss_profile_disable()
d
float d[1024]
Definition
test_iir_biquad.c:13
y_ref
float y_ref[1024]
Definition
test_iir_biquad.c:16
dsps_biquad_f32_aes3
esp_err_t dsps_biquad_f32_aes3(const float *input, float *output, int len, float *coef, float *w)
N_SAMPLES
#define N_SAMPLES
Definition
test_iir_biquad.c:10
test_iir_biquad
void test_iir_biquad()
Definition
test_iir_biquad.c:22
xt_iss_profile_enable
void xt_iss_profile_enable()
N
#define N
Definition
test_mmult.c:13
components
espressif__esp-dsp
modules
iir
test_sim
test_iir_biquad.c
Generated by
1.16.1