FIR Filter delay for Realtime Signal Processing

2 views (last 30 days)
Hello everyone, i am trying to simulate a realtime signal processing through simulink with all of these block in the picture below. Without the filter, it works fine. But as soon as the filter is introduced we can see a big delay with only 501 filterkoef. Why is this happening ? What can i do to fix this delay ? As for the coefficients, i should be using an impuls where i recorded a clap in my room and then transfer it to matlab. but for the sake of testing i used this instead : filterkoef = [ zeros(1,500) 1 ].

Answers (1)

Christopher McCausland
Christopher McCausland on 26 May 2021
Hi Ghazian,
Your question is more about sampling theroy than matlab. Using an FIR filter will intorduce group delay to the signal. i.e. there is a delay from the signal entering the FIR filter to the signal being output. Group Delay can be calculated as:
Where N is the number of filter taps and T is the sampling time
Where N is the number of filter taps and T is the sampling time. Assuming a sample frequency of T is 20 Hz, the expected phase delay is 12.5 seconds provided the FIR filter is linear which is about what your image shows.
Are you sampling the signal at a sufficently high enough frequency, I would expect 48 khz or so?
Christopher
  1 Comment
Ghazian Ghaffar Amna
Ghazian Ghaffar Amna on 27 May 2021
Hi Christopher,
yes i am sampling it at 44.1kHz so i think its already high enough.
as for delay, i asked around in reddit and someone found the answer.
its because the microphone process it in frame based and not sampled based.
and we can change that in the block setting of the microphone.
Ghazian

Sign in to comment.

Categories

Find more on Get Started with DSP System Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!