3
\$\begingroup\$

I am trying to pass a .wav sound waveform through a band pass filter whose impulse response is given by

\$ h(t)=50u(t) \exp(-10t) \sin(2 \pi 440t), \$

I have imported the file into Matlab as follows:

[s, Fs] = wavread('piano_chord.wav');

So, what syntax do I need to use to implement this filter?

I have looked at the [b,a] = butter(n,Wn) or [b,a] = cheby1(n,Rp,Wp) for Butterworth and Chebyshev band-pass filters respectively. But I don't know how the equation for impulse response factors into this, and what values I need to use for a, b, and Wn.

Any help would be greatly appreciated.

\$\endgroup\$
1
\$\begingroup\$

create a timebase for your impulse response:

t = 0 : 1/fs : 1;

create the impulse response

b = 50 * exp( -10*t ) .* sin( 2*pi*440*t );

filter the signal

filtered_s = filter( b, 1, s);
\$\endgroup\$
  • \$\begingroup\$ And when I use the wavwrite(filtered_s, Fs, 'band_pass') syntax I get the error: Warning: Data clipped during write to file:band_pass. How else can I export the filtered signal? \$\endgroup\$ – Merin Apr 22 '16 at 8:38
  • \$\begingroup\$ Never mind, it worked fine. Thank you so much for the help. \$\endgroup\$ – Merin Apr 22 '16 at 12:13
1
\$\begingroup\$

If you already have the impulse response you want, the simplest approach would be to simply convolve that with the signal, effectively implementing an FIR filter.

The alternative would be to do an FFT of the impulse response to get the frequency response, and then try to approximate that with a bank of conventional (e.g., Butterworth or Chebyshev) filters.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.