How to apply an IIR-Filter correctly on a PCM-Signal?

6 次查看(过去 30 天)
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
Error using readtable
Unable to find or open 'idealMLS32768.txt'. Check the path and filename or file permissions.
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)|')

采纳的回答

Jan
Jan 2022-7-5
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 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with DSP System Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by