I want to remove all the frequency components from a .wav file except those within \$\pm 25\$ of \$523 \ Hz\$ as well as its harmonics.
Attempt:
I used a high pass filter first to suppress frequencies below 523 - 25 Hz. Then I used a low pass filter to suppress frequencies higher than 523 + 25. If my method is correct, is there a more efficient way of doing this?
Also, to take into account the harmonics, I used a 'for loop'. Is that right? But it only removes up to a certain harmonic. Is it possible to modify this code so that it repeats the procedure for all of the harmonics of 523 Hz, up to the Nyquist frequency?
Here's my Matlab code:
[s, Fs] = wavread('chord.wav');
wavplay(s, Fs);
n=input('Number of harmonics? ');
for N=2:1:n
% High-pass filter
FsNorm = (523-25).*N / (Fs/2);
[b, a] = butter(10, FsNorm, 'high');
sHigh = filtfilt(b, a, s);
% Low pass filter
FsNorm = (523+25).*N / (Fs/2);
[b,a] = butter(10, FsNorm, 'low');
sLow = filtfilt(b, a, s);
end
wavplay(sLow,Fs);