i konw that the human voice frequency between 200 to 3200 H and i record wave file ,how can i filter this wave ile so only human voice (frequency between 200 to 3200) will stay in the wave file
for record i use
Fs = 8000;
y = wavrecord(10*Fs, Fs, 'double');

2 件のコメント

Walter Roberson
Walter Roberson 2012 年 10 月 3 日
Do you have the signal processing toolbox? The filter design toolbox?
Abdulkareem
Abdulkareem 2012 年 10 月 4 日
yes sir i have signal processing toolbox and i read Filter Design HDL Coder on help

サインインしてコメントする。

 採用された回答

Honglei Chen
Honglei Chen 2012 年 10 月 4 日

0 投票

Let's say the passband is between 200 and 3200 Hz and the stop band is 100 and 3300 Hz, you can use a Butterworth filter
Ws = [100 3300]/(Fs/2);
Wp = [200 3200]/(Fs/2);
[N,Wn] = buttord(Wp,Ws,0.1,30);
[b,a] = butter(N,Wn);
filter(b,a,y)
If you want more options to design your filter, try fdatool

4 件のコメント

Ahmet Ozan Tatlisu
Ahmet Ozan Tatlisu 2017 年 4 月 17 日
i tried to apply your answer but i receive an error below Audio data must be real and floating point. while trying to listen the filtered data
file1='mike.wav';
file2='street.wav';
[y1 Fs]=audioread(file1);
[y2 Fs]=audioread(file2);
y=y1+y2;
y=fft(y);
Ws = [100 3300]/(Fs/2);
Wp = [200 3200]/(Fs/2);
[N,Wn] = buttord(Wp,Ws,0.1,30);
[b,a] = butter(N,Wn);
y=filter(b,a,y);
y=ifft(y);
sound(y,Fs);
my code is like this i also tried to use isnan function to handle this error because there is some NaN s in the vector when i filtered it,but i couldnt do this. Do you have some help ?
Honglei Chen
Honglei Chen 2017 年 4 月 17 日
You don't need to do y=fft(y) and y=ifft(y), the filtering operation is on time domain data.
Ahmet Ozan Tatlisu
Ahmet Ozan Tatlisu 2017 年 4 月 19 日
oh ok but i have a homework that my instructer wants me to do filtering in frequency domain idk how to do, can you help ?
Walter Roberson
Walter Roberson 2017 年 4 月 19 日
The fft of the real-valued sound is going to give you a complex result where the second half is the complex conjugate of the reflection of the first half, similar to
[F, conj(fliplr(F))]
When you have that particular pattern of complex data then ifft() if it will give a real result.
However, your butter filter is not leaving your data in that pattern, so when you ifft() the result you will not get something that is real-valued, and then sound() will not be able to handle it.
If you were to apply your filter to only the first half of the data, and then put that together with the complex conjugate of its reflection, then you would get something that could be ifft()'d.
Note, though, that I simplified the pattern a little: what I wrote is for the case where the number of samples is even. In the case where the number of samples is odd, the midpoint of the fft will be real-valued and so will be its own complex conjugate.
Applying butter() to the result of fft() does not make much sense, but it is possible if you take the steps I describe.
You should be using a different technique to filter in the frequency domain.

サインインしてコメントする。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by