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
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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with DSP System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!