How to apply an IIR-Filter correctly on a PCM-Signal?
9 views (last 30 days)
Show older comments
I don't know much about filters yet and am just trying things out. I wanted to apply a "pink filter" to my measurement signal (maximum-length-sequence). I got the parameters for the IIR from this page: ccrma.stanford.edu. When I plot the filter, everything looks correct to me. However, when I apply the filter to the measurement signal, it is so quiet that you almost can't hear it anymore. In the original, the measurement signal is in full scale and jumps between 1 and -1. How can this be, what am I doing wrong?
Here's my code:
In=readtable("idealMLS32768.txt"); %In is an Array filled with 32768 points
Dirac = [1;zeros(32768-1,1)]; %Dirac could be used to demonstrate the filter instead of the Variable In
%Fs=48000.0;
b = [0.049922035 -0.095993537 0.050612699 -0.004408786];
a = [1 -2.494956002 2.017265875 -0.522189400];
iir = dsp.IIRFilter('Numerator',b,'Denominator',a);
Out=iir(In.Var1); % here i want to apply the filter to the pcm-audio input.
plot(Out)
%fvtool(iir,'Fs',Fs);
Y=fft(Out);
P = sqrt(real(Y).^2+imag(Y).^2);
P=20*(log(P)/log(10));
plot(f,P(1:n/2+1))
set(gca, 'XScale', 'log')
title('FFT')
xlabel('Frequency (f)')
ylabel('|P(f)|')
0 Comments
Accepted Answer
Jan
on 5 Jul 2022
Yes, this filter reduces the power massively:
data = load('handel.mat');
signal = data.y;
b = [0.049922035 -0.095993537 0.050612699 -0.004408786];
a = [1 -2.494956002 2.017265875 -0.522189400];
filtered = filter(b, a, signal);
plot(signal, 'b');
hold on;
plot(filtered, 'r')
0 Comments
More Answers (0)
See Also
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!