I'm trying to combine two filters into a single filter command for a homework problem and was looking for advice. I don't necessarily need an explicit answer as long as someone can point me in the right direction.
In the following code, assume that 'y' is a sound file that has been pre-loaded (10kHz). Also, both the hlpf and hnotch filters work together separately to produce an audio signal with noise and a beeping tone removed. However, when I try to combine the two into a single filter, I do not achieve this result. Here is my code:
Fs = 10000;
f0 = 1000; %#notch frequency
fn = Fs/2; %#Nyquist frequency
freqRatio = f0/fn; %#ratio of notch freq. to Nyquist freq.
notchWidth = 0.1; %#width of the notch
%Compute zeros
zeros = [exp( sqrt(-1)*pi*freqRatio ), exp( -sqrt(-1)*pi*freqRatio )];
%Compute poles
poles = (1-notchWidth) * zeros;
b = poly( zeros ); %# Get moving average filter coefficients
a = poly( poles ); %# Get autoregressive filter coefficients
hnotch = [poly(poles)];
alpha = 0.42;
hlpf = fir1(100, alpha);
hcombo = conv(hlpf,hnotch);
s2 = filter(hcombo,1,y);
soundsc(s2,Fs)
Any help would be greatly appreciated.