DSPRelated.com
Forums

Audio filtering

Started by Sreeram December 25, 2004
Hello,

I am trying to do an audio filter program. I need to filter out certain 
frequencies from the audio data. I am doing FFT, Bandpass & IFFT.

But after doing FFT, I am 0'ing out the bins for my desired frequency 
range. After that I am doing Inverse FFT. But the playing audio is not
proper and a "tick tick" is comming in the audio output.

I need to do the filtering for all PCM formats including stereo/mono &
8/16bit with all samplerates.

Anybody can suggest me what could be the possible reason? I also see 
about IIR in time domain. Anybody can explain me the best method I 
should follow? Is there any C source code available?

Thanks,
Sreeram.
zeroing in the frequency domain is much too crude a method.
Investigate time domain methods
The clicks are likely from the FFT/IFFT process

Fred

"Sreeram" <sreeram@spymac.com> wrote in message 
news:1104000624.00d162d05ec9cc8769c436cd297c753c@teranews...
> Hello, > > I am trying to do an audio filter program. I need to filter out certain > frequencies from the audio data. I am doing FFT, Bandpass & IFFT. > > But after doing FFT, I am 0'ing out the bins for my desired frequency > range. After that I am doing Inverse FFT. But the playing audio is not > proper and a "tick tick" is comming in the audio output. > > I need to do the filtering for all PCM formats including stereo/mono & > 8/16bit with all samplerates. > > Anybody can suggest me what could be the possible reason? I also see about > IIR in time domain. Anybody can explain me the best method I should > follow? Is there any C source code available? > > Thanks, > Sreeram.
Fred Marshall wrote:
> zeroing in the frequency domain is much too crude a method. > Investigate time domain methods > The clicks are likely from the FFT/IFFT process > > Fred
You need to overlap, too. look up "overlap-add" or "overlap-save".
> "Sreeram" <sreeram@spymac.com> wrote in message > news:1104000624.00d162d05ec9cc8769c436cd297c753c@teranews... > >>Hello, >> >>I am trying to do an audio filter program. I need to filter out certain >>frequencies from the audio data. I am doing FFT, Bandpass & IFFT. >> >>But after doing FFT, I am 0'ing out the bins for my desired frequency >>range. After that I am doing Inverse FFT. But the playing audio is not >>proper and a "tick tick" is comming in the audio output. >> >>I need to do the filtering for all PCM formats including stereo/mono & >>8/16bit with all samplerates. >> >>Anybody can suggest me what could be the possible reason? I also see about >>IIR in time domain. Anybody can explain me the best method I should >>follow? Is there any C source code available? >> >>Thanks, >>Sreeram.
Thank you for your reply. Now I am looking into the BiQuad filter.

I am bit confused or do not know the usage of certain coefficients.

How to calculate:
1. Center frequency
2. bandwidth in Octaves
3. dBGain

I have the following values as input. LowFreq, HighFreq, MinGain & MaxGain.

Also when I am doing a bandpass filtering in the range 1000 to 5000Hz, 
will I get any signal in other frequency points, (say in 500Hz).?

Thank you,
Sreeram.




Fred Marshall wrote:
> zeroing in the frequency domain is much too crude a method. > Investigate time domain methods > The clicks are likely from the FFT/IFFT process > > Fred > > "Sreeram" <sreeram@spymac.com> wrote in message > news:1104000624.00d162d05ec9cc8769c436cd297c753c@teranews... > >>Hello, >> >>I am trying to do an audio filter program. I need to filter out certain >>frequencies from the audio data. I am doing FFT, Bandpass & IFFT. >> >>But after doing FFT, I am 0'ing out the bins for my desired frequency >>range. After that I am doing Inverse FFT. But the playing audio is not >>proper and a "tick tick" is comming in the audio output. >> >>I need to do the filtering for all PCM formats including stereo/mono & >>8/16bit with all samplerates. >> >>Anybody can suggest me what could be the possible reason? I also see about >>IIR in time domain. Anybody can explain me the best method I should >>follow? Is there any C source code available? >> >>Thanks, >>Sreeram. > > >
Sreeram wrote:

> Thank you for your reply. Now I am looking into the BiQuad filter. > > I am bit confused or do not know the usage of certain coefficients. > > How to calculate: > 1. Center frequency > 2. bandwidth in Octaves > 3. dBGain > > I have the following values as input. LowFreq, HighFreq, MinGain & MaxGain. > > Also when I am doing a bandpass filtering in the range 1000 to 5000Hz, > will I get any signal in other frequency points, (say in 500Hz).? > > Thank you, > Sreeram.
... Frequencies outside the passband are attenuated, not (in general) removed. Frequencies within the passband are affected only slightly by attenuation, and the effects on those near the edges fall between. Plot the response of your filter and you will see. Transitions can be made more abrupt, attenuation out of band greater and passbands flatter by increasing the order of the filter. There are costs for doing that. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
I have been reading the "Cookbook formulae for audio EQ biquad filter 
coefficients".

"f0 ("wherever it's happenin', man."  Center Frequency or Corner 
Frequency, or shelf midpoint frequency, depending on which filter type. 
  The "significant frequency".)"

I didn't exactly understand what it means. How to calculate this when I 
have low and high frequency level?

"dBgain (used only for peaking and shelving filters)" & "BW the 
bandwidth in octaves (between -3 dB frequencies for BPF and notch or 
between midpoint (dBgain/2) gain frequencies for peaking EQ)"

Could you please explain me what these parameters are and how to use it?

Thank you,
Sreeram.

> > ... > > Frequencies outside the passband are attenuated, not (in general) > removed. Frequencies within the passband are affected only slightly by > attenuation, and the effects on those near the edges fall between. Plot > the response of your filter and you will see. Transitions can be made > more abrupt, attenuation out of band greater and passbands flatter by > increasing the order of the filter. There are costs for doing that. > > Jerry
"Sreeram" <sreeram@spymac.com> wrote in message
news:1104135785.5c31aaf8c0f8a2e2a4826428df08a6dc@teranews...
> I have been reading the "Cookbook formulae for audio EQ biquad filter > coefficients". > > "f0 ("wherever it's happenin', man." Center Frequency or Corner > Frequency, or shelf midpoint frequency, depending on which filter type. > The "significant frequency".)" > > I didn't exactly understand what it means. How to calculate this when I > have low and high frequency level?
The center frequency would be the geometric average of your low and high frequencies. In other words f0 = square_root(low frequency * high frequency).
> "dBgain (used only for peaking and shelving filters)" & "BW the > bandwidth in octaves (between -3 dB frequencies for BPF and notch or > between midpoint (dBgain/2) gain frequencies for peaking EQ)"
Are you using the peaking filter or the bandpass filter? If you are using the "(constant 0 dB peak gain)" bandpass filter, you can ignore the dB gain. Bandwidth in octaves can be calculated as log2(high frequency/low frequency), where log2 is the base 2 logarithm. Keep in mind that if you use a single biquad filter, your attenuation at the band edges will only be 3dB (increasing as you get farther from the band edge). You may want to use several biquads in series to get additional attenuation. The optimal solution probably involves using different settings for each biquad so that the composite result is as flat and sharp as possible.
> Could you please explain me what these parameters are and how to use it? > > Thank you, > Sreeram. > > > > > ... > > > > Frequencies outside the passband are attenuated, not (in general) > > removed. Frequencies within the passband are affected only slightly by > > attenuation, and the effects on those near the edges fall between. Plot > > the response of your filter and you will see. Transitions can be made > > more abrupt, attenuation out of band greater and passbands flatter by > > increasing the order of the filter. There are costs for doing that. > > > > Jerry
Thank you. I have few more doubts.

Jon Harris wrote:
 >
 > Are you using the peaking filter or the bandpass filter?  If you are 
using the
 > "(constant 0 dB peak gain)" bandpass filter, you can ignore the dB gain.

I am doing a bandpass filter.

 >
 > Keep in mind that if you use a single biquad filter, your attenuation 
at the
 > band edges will only be 3dB (increasing as you get farther from the 
band edge).
 > You may want to use several biquads in series to get additional 
attenuation.
 > The optimal solution probably involves using different settings for 
each biquad
 > so that the composite result is as flat and sharp as possible.
 >

I didn't understand this portion correctly. I calculated the values for
center frequency & bandwidth in octaves. I am doing a bandpass filter in
the range 10000 to 15000Hz. But after filtering I am getting signals
even in other areas. The data after filter is not proper as expected.
And it plays full.

Are you saying, after a bandpass filtering I need to run the same
through a low pass and high pass filter to get the correct output?

Please correct me if I am wrong and a possible solution. An explanation
with a simple example would be really helpful.

Thank you,
Sreeram
"Sreeram" <sreeram@spymac.com> wrote in message
news:1104255027.7a2f0acb86687b028e1a5f692bf01cf7@teranews...
> Thank you. I have few more doubts. > > Jon Harris wrote: > > > > Are you using the peaking filter or the bandpass filter? If you are > using the > > "(constant 0 dB peak gain)" bandpass filter, you can ignore the dB gain. > > I am doing a bandpass filter. > > > > > Keep in mind that if you use a single biquad filter, your attenuation > at the > > band edges will only be 3dB (increasing as you get farther from the > band edge). > > You may want to use several biquads in series to get additional > attenuation. > > The optimal solution probably involves using different settings for > each biquad > > so that the composite result is as flat and sharp as possible. > > > > I didn't understand this portion correctly. I calculated the values for > center frequency & bandwidth in octaves. I am doing a bandpass filter in > the range 10000 to 15000Hz. But after filtering I am getting signals > even in other areas. The data after filter is not proper as expected. > And it plays full.
What I am trying to say is that a biquad bandpass filter is nowhere near an "ideal" band pass filter which has 0 attenuation in the center pass-band and infinite attenuation outside of it. Have you ever seen the graph of the frequency response of a biquad band-pass filter? If not, take a look at some of these links: http://www.iitk.ac.in/eclub/ee381/Expt1_Biquad_Active_Filter.pdf http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/bp.htm In your case, if you bandpass filter is from 10000 to 15000 Hz, a signal at 9999 Hz is only going to be attenuated by 3dB, not completely eliminated. Components further from the edges, such as 100 Hz will be much more strongly attenuated.
> Are you saying, after a bandpass filtering I need to run the same > through a low pass and high pass filter to get the correct output?
No, I'm saying you might get better results by running the signal through the biquad multiple times, i.e. feed the filtered output back into the biquad input.
> Please correct me if I am wrong and a possible solution. An explanation > with a simple example would be really helpful.
Hope the above is helpful to you. I think the main problem is your expectation of what a single biquad bandpass filter is capable of. Have a look at the above links and adjust your expectations accordingly. -Jon
Thank you, Jon, for your patience.

> >>Are you saying, after a bandpass filtering I need to run the same >>through a low pass and high pass filter to get the correct output? > > > No, I'm saying you might get better results by running the signal
through the
> biquad multiple times, i.e. feed the filtered output back into the
biquad input.
> >
Now I have generated coefficients for 1 biquad. I cannot use same biquad coeffcients for further filtering. right? How I should calculate further biquad coefficients for further filtering? Also, could you please recomend me some book which describes about filters in audio programming(with some C/C++ code if it is available)? It would be better if that book is available in asian countries. Many good foreign technical books will not get in India. (normally) Thank you, Sreeram.