Hey again readers, spent a couple of hours researching filter simulation in Matlab and got a few things figured out.
Right now my code uploads a wav, applies a 1st order butterworth low pass filter to it, and plays the filtered wav file back. That all is working fine. The challenge I am facing is somehow changing the cutoff frequency while the program is running so the sound "opens up and closes" during playback.
Here's how I'm approaching this right now:
------------
This function samples (at the sample rate, fs) the wav file and stores those samples in the matrix x. x is a 2 by 37000ish matrix that contains a discrete representation of the wav file. I'm currently using a short ringtone for code testing as opposed to a full guitar track.
[x fs]=wavread('Bangarang_Phone.wav');
I then set my cutoff frequency whic for the filter U currently have is 900 hz.
Fc=900;
Then I use a butterworth function to implement a 1st order low pass filter.
w = Fc/(2*fs); % Normalized frequency
[b,a]=butter(1,w,'low'); %1st order butterworth LPF
y=filter(b,a,x); % pass the input signal through the filter
Then play the filtered sound
sound(y,fs)
------------
That's what I have so far. I'm thinking I need to somehow implement a loop and change Fc as the filter is being applied. I just don't know how to do this though. That's for another hour!
More soon,
-Mark
No comments:
Post a Comment