I'm trying to implement a biquad filter in my I2S stream on my MC Audio evaluation board, but when I filter the samples, e.g. with a low-pass filter with a corner frequency of 1kHz, I get an output signal as if the filter was a low-pass at 2kHz.

I created the coefficients with the filter design function in the dsp library and simulated the frequency response of these coefficients with a Python script. The coefficients are valid.

The part of my code responsible for applying the filter is the following:

#include "i2s.h" #include "dsp.h" #define SAMPLING_FREQUENCY 48000 #define Q_FORMAT 24 void audio_filter(streaming chanend c_dsp) { int32_t in_sample[CHANNEL_COUNT] = {0}; // Holds the incoming sample int32_t out_sample[CHANNEL_COUNT] = {0}; // Holds the outgoing sample double filter_fq = 1000.0/SAMPLING_FREQUENCY; // Sets the corner frequency of the filter double filter_q = 0.707; // Sets the Q factor of the filter int32_t filter_state[4] = {0}; dsp_design_biquad_lowpass(filter_fq, filter_q, coeffs, Q_FORMAT); // calculates the biquad coefficients for the filter while (1) { /* Exchanges samples with the i2s handler */ for (size_t i = 0; i < CHANNEL_COUNT; i++) { c_dsp :> in_sample; c_dsp <: out_sample; } /* Applies the filter to the sample */ for (size_t i = 0; i < CHANNEL_COUNT; i++) { out_sample= dsp_filters_biquad(in_sample, coeffs, filter_state, Q_FORMAT); } } }

Before that, there is an i2s handler function that manages the conversion of i2s to samples and sends new samples to the filter function via the channel c_dsp and vice versa.

I also included a picture of a messured filter with a corner frequency of 1kHz and a Q factor of 0.707:Before that, there is an i2s handler function that manages the conversion of i2s to samples and sends new samples to the filter function via the channel c_dsp and vice versa.

I also included a picture of a messured filter with a corner frequency of 1kHz and a Q factor of 0.707:

I work with xTimeComposer 14.4.1, the xc language and the dsp library. The code runs on an MC Audio Eval Board with XCore-200 Chip.

I don't know what I did wrong.I would be very grateful for any help!

Many thanks in advance!

Best regards

Till