DSPRelated.com
Forums

DFT and bandpass filters

Started by Michel Rouzic June 2, 2005
"Andor" <an2or@mailcircuit.com> wrote in message
news:1118071163.455338.287340@g14g2000cwa.googlegroups.com...
> > Since the energy content of music -- the usual input > > to these displays -- decreases with frequency, the input is often > > differentiated to create a more pleasing display. > > Interesting - this is the first time I hear of that. I'm not sure I > would be very pleased with a spectrum anlayzer with such behaviour, > though.
I'm guessing Jerry is referring to the "gee whiz" bouncing line displays used on car stereos, PC media players, and some home stereos, as opposed to analyzers used by audio professionals to measure the frequency response of the a room.
Andor wrote:
>>Since the energy content of music -- the usual input >>to these displays -- decreases with frequency, the input is often >>differentiated to create a more pleasing display. > > > Interesting - this is the first time I hear of that. I'm not sure I > would be very pleased with a spectrum anlayzer with such behaviour, > though. I know that sometimes A-weighting is applied to accomodate > psychoacoustic effects, which is about equal to a differntiator > followed by a two-point average (raised cosine). Did you mean that?
No, I didn't. I guessed that we aren't discussing a spectrum analyzer, but rather something that could be called a "light organ". Often, these are snazzy adjuncts to ten-channel graphic equalizers, and about as useful. They can be fun to build and get working. Cheap, too. With all the processing done on a home computer, the output can be displayed on the monitor. A great display is a bar graph with each bar's color changing according to intensity.
>>When you listen to an impulse, where does it _sound_ like the energy is >>concentrated? > > > Hard to say ... everywhere?
To me, a click seem to have high pitch, precisely because it is actually flat. When sounds aren't weighted to the low end, they seem to have emphasized highs. Emphasizing the highs for display makes them look like they sound. The customer is always right, engineers notwithstanding.
> ;-)
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;
BobM wrote:
> Michel Rouzic wrote: > >>that's one more thing i dont understand, why do i need FIR coefficients >>and overlap-add or overlap-save to do a bandpass filter? i think jerry >>avins is right all i need is a window. > > > I think Jerry means that if you only want to make a spectrogram display > from the frequency domain bin amplitudes, then you only need to do the > following: > > 1. Window the time domain data > 2. FFT the windowed data > 3. Group the bins into logarithmically spaced groups > 4. Plot your amplitudes based on the grouped bins > 5. Repeat for the next block of data
That's what I meant.
> However, if you want to do a _bandpass_ filter, with the intention of > returning the data to the time domain, my understanding is that you > will also need FIR coefficients which you will multiply the data by in > the frequency domain. In addition, you will need to use Overlap-Add or > Overlap-Save to avoid time-domain wrap-around effects from doing this > multiplication in the frequency domain. Again, this is only if you > intend on returning the data to the time domain as (bandpass) filtered > data.
True enough, but I think that's beside the point for what Michel wants to do (if I understand him correctly). We'll help him more by directing his attention to what matters to him now. ... 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;
"Jerry Avins" <jya@ieee.org> wrote in message
news:KLadnQgO8J-QFjnfRVn-tA@rcn.net...
> Andor wrote: > >>Since the energy content of music -- the usual input > >>to these displays -- decreases with frequency, the input is often > >>differentiated to create a more pleasing display. > > > > > > Interesting - this is the first time I hear of that. I'm not sure I > > would be very pleased with a spectrum anlayzer with such behaviour, > > though. I know that sometimes A-weighting is applied to accomodate > > psychoacoustic effects, which is about equal to a differntiator > > followed by a two-point average (raised cosine). Did you mean that? > > No, I didn't. I guessed that we aren't discussing a spectrum analyzer, > but rather something that could be called a "light organ". Often, these > are snazzy adjuncts to ten-channel graphic equalizers, and about as > useful. They can be fun to build and get working. Cheap, too. With all > the processing done on a home computer, the output can be displayed on > the monitor. A great display is a bar graph with each bar's color > changing according to intensity.
The latest Windows Media player has several different "visualizations" that work kind of like this. With all the processing power available on the modern PC, they have a whole lot of bands too (I'm guessing >500). I have found this is especially nice to watch while listening to solo piano music--you can "see" what keys are being played.
Jon Harris wrote:

> The latest Windows Media player has several different "visualizations" that work > kind of like this. With all the processing power available on the modern PC, > they have a whole lot of bands too (I'm guessing >500). I have found this is > especially nice to watch while listening to solo piano music--you can "see" what > keys are being played.
Are their displays flat, or more sensitive to highs? 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;
"Jerry Avins" <jya@ieee.org> wrote in message
news:XPGdnbuCopx3MznfRVn-qw@rcn.net...
> Jon Harris wrote: > > > The latest Windows Media player has several different "visualizations" that
work
> > kind of like this. With all the processing power available on the modern
PC,
> > they have a whole lot of bands too (I'm guessing >500). I have found this
is
> > especially nice to watch while listening to solo piano music--you can "see"
what
> > keys are being played. > > Are their displays flat, or more sensitive to highs?
With white noise playing, the display is tilted up to the right, i.e. it shows more high frequency content than low. With pink noise, the display looks essentially flat. So it looks like it is calibrated so that equal energy per octave rather than equal energy per Hz generates a flat response, but there is no additional weighting.
Jon Harris wrote:
> "Jerry Avins" <jya@ieee.org> wrote in message > news:XPGdnbuCopx3MznfRVn-qw@rcn.net... > >>Jon Harris wrote: >> >> >>>The latest Windows Media player has several different "visualizations" that > > work > >>>kind of like this. With all the processing power available on the modern > > PC, > >>>they have a whole lot of bands too (I'm guessing >500). I have found this > > is > >>>especially nice to watch while listening to solo piano music--you can "see" > > what > >>>keys are being played. >> >>Are their displays flat, or more sensitive to highs? > > > With white noise playing, the display is tilted up to the right, i.e. it shows > more high frequency content than low. With pink noise, the display looks > essentially flat. So it looks like it is calibrated so that equal energy per > octave rather than equal energy per Hz generates a flat response, but there is > no additional weighting.
I was wrong then. With a nod to Andor. 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;
> 1. Window the time domain data > 2. FFT the windowed data > 3. Group the bins into logarithmically spaced groups > 4. Plot your amplitudes based on the grouped bins > 5. Repeat for the next block of data
Well, i don't think that windowing in the time domain is a good idea. plus, i dont think it can get low frequencies, as i'm interested in low frequencies. and just picture that, if i decide to analyse 640 bands, knowing how they are logarithmically spaced, how big would the window in the time domaine have to be? really, i think the idea of doing a bandpass, then and envelope to put it as a line in an image file isnt too bad.
> However, if you want to do a _bandpass_ filter, with the intention of > returning the data to the time domain, my understanding is that you > will also need FIR coefficients which you will multiply the data by in > the frequency domain. In addition, you will need to use Overlap-Add or > Overlap-Save to avoid time-domain wrap-around effects from doing this > multiplication in the frequency domain. Again, this is only if you > intend on returning the data to the time domain as (bandpass) filtered > data.
thats what i dont understand, why do i need to do FIR coefficients and overlap-add or save to do a bandpass filter, considered the way i want to do it? because in the first place my bandpass worked fine, besides the artifacts that can be solved by appling a kind of window function in the frequency domain before performing an IFFT.
> The second link I gave you in the previous post has a good explanation > of what Overlap-Save is, and how to implement it. Overlap-Add and > Overlap-Save are the methods used for FFT convolution. If you don't use > one of these methods and you try to filter in the frequency domain and > return to the time domain, you will get wrap-around effects in the time > domain.
I read your link and after all i read, i still dont really know what overlap-save/add, fft convolution and warp-around effects are or are for.
> Using a time-domain window will reduce artifacts in the frequency > domain.
why?? i really dont understand that! when you perform a FFT, you have no artifacts in the frequency domain
> I'm not clear as to what artifacts you're referring to
well, do this : FFT a sound that at some part contains a silence, zero all the samples that arent in the frequency range that you want to pass, then IFFT, and you'll notice that the silences arent silent anymore and are made of two sines matching to the lowest and highest frequency of your little bandass filter.
> True enough, but I think that's beside the point for what Michel wants > to do (if I understand him correctly). We'll help him more by directing > his attention to what matters to him now.
Yes, you understood correctly i think. By the way, it seems like no one wants to reply to that post that matters pretty much to me, so here it is again : i think my idea was kinda different. it consists of : -performing a FFT -calculate every frequency needed, provided a lower frequency, a upper frequency and the number of bands to do (i guess i'll mostly use values between 500 and 1000), according to the log base 2 thing so i have a lways the same number of bands for an octave (thus if you choose 640 bands for 10 octaves, you'll have 64 bands/octave) -do a band pass for each band -do a IFFT for each band -calculate each bands envelope (i heard of a function to do that, but right now its not my main concern) -output each band as a line in a .bmp file (already got a function that writes grey .bmp files) the problem with that, is that i'll get quite smooth results, given the relative narrowness of the bands, mostly for the lowest frequencies. i was considering a trick, but i dont know whether it would give bogus results or not. the idea is this, in order to obtain a sharper enveloppe for a given band, it would be to calculate the envelope of the original wave, then calculate the enveloppe of the bandstopped wave (i mean that instead of doing a bandpass for the band i want to obtain the envelope, i would rather do a bandstop to exclude the chosen range of frequencies), and then substract the second enveloppe to the second to obtain a envelope of the band. is it a stupid idea, i mean, would it give a totally bogus result that doesnt match to reality or is it something i should try to do? by the way, i was thinking, when you do the DFT of lets say 256 samples in the time domain, you can't detect some frequencies that are under a certain limit, right? because i heard about i trick which consists on taking for example 256 samples in the time domain, and add a huge number of zero's after those 256 samples so you're FFT has much more points. thats quite seducing but it made me think it probably prevents you from detecting low frequencies, right?
Michel Rouzic wrote:

> i think my idea was kinda different. it consists of : > > -performing a FFT > -calculate every frequency needed, provided a lower frequency, a upper > frequency and the number of bands to do (i guess i'll mostly use values > between 500 and 1000), according to the log base 2 thing so i have a > lways the same number of bands for an octave (thus if you choose 640 > bands for 10 octaves, you'll have 64 bands/octave) > -do a band pass for each band > -do a IFFT for each band > -calculate each bands envelope (i heard of a function to do that, but > right now its not my main concern) > -output each band as a line in a .bmp file (already got a function that > writes grey .bmp files)
Michel, I think you just need to slow down for a moment, sit back, turn off your computer (well, at least your programming environment) and think about what you need, and how you want to achieve that. I gathered the following: 1. You want to program a spectrum analyzer. 2. You are thinking about 64bands / octave. A question: to what kind of signals do you want to apply your analyzer? Music? Speech? Are you sure you really need 64bands / octave (ie. more than five bands for a single half-tone)? 3. You want to use FFT to implement bandbass filters (this is possible), and at the same time you say that the FFT does not give you good enough resolution for low frequencies, so you cannot take the output of the FFT directly for your analyzer. But how do you think you can specify the bandpass filters with the FFT? You'll face the same problem of too little resolution when you want to implement the low frequency 64bands / octave bandpasses. An example: look at the octave of 20 Hz - 40 Hz. You want a resolution of 64 bands , ie. 20 / 64 ~= 0.3125 Hz / band. At 44.1 kHz sampling rate you'll need an FFT of at least 44100 / 0.3125 = 1'241'120 points to only specify the bandpass filters. You'll need even more if you want to use fast convolution. There are several ways to achieve what you want. I still maintain that a simple (but large enough) FFT will give you just that (by using interpolation in the low frequencies). Another option is to use the bandpass filters, but I would suggest IIR filters (as phase is not important for the analyzer, and low-frequency bandpass FIR filters are hard to implement). However, the first step in finding the best solution is to specify the task. Ask yourself: how many bands (what information do I want from the analyzer about the signal)? Does it need to be real-time? What kind of hardware / software will the spectrum analyzer run on? I hope this helps some. Regards, Andor