I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 through 64 (total 65 points)? And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I consider 64 through 128 (total 65 points)? _____________________________ Posted through www.DSPRelated.com
How to plot magnitude spectrogram of lower and upper half of frequency range?
Started by ●August 9, 2013
Reply by ●August 9, 20132013-08-09
"EthanHarvard" <98300@dsprelated> writes:> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I > want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 > through 64 (total 65 points)? > > And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I > consider 64 through 128 (total 65 points)?Yes. Half of the result of the FFT of a real signal is redundant because of Hermitian symmetry: H(f) = H*(-f) -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●August 9, 20132013-08-09
On Friday, August 9, 2013 12:06:32 AM UTC-4, EthanHarvard wrote:> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I > > want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 > > through 64 (total 65 points)? > > > > And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I > > consider 64 through 128 (total 65 points)? > > > > > > > > _____________________________ > > Posted through www.DSPRelated.comHello Ethan, Yes, you are considering the correct points (there can be exceptions though). To test your algo create a test sinusoid, i.e., y_n = cos(2pi*f*n/8000) where n=0,1,2,3,...,254,255 and f is your frequency in hetz. Then you will know for sure where your frequencies "show up" in the data vector. Sometimes an FFT's result can be centered meaning that instead of the DC (0 hertz) bin being the first data element, it will show up in the middle (element 128) - everything is moved over half a buffer length with the data being wrapped around the buffer. IHTH, Clay
Reply by ●August 9, 20132013-08-09
Randy Yates <yates@digitalsignallabs.com> writes:> "EthanHarvard" <98300@dsprelated> writes: > >> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I >> want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 >> through 64 (total 65 points)? >> >> And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I >> consider 64 through 128 (total 65 points)? > > Yes.Sorry, I didn't notice your +1's, so no, that's not right. The first half would be 0 to 63; second half 64 to 128 (65 points), if you wanted to catch the last term at Fs/2. Most people don't plot that last point and just take 0 to N/2 - 1 for an even N-point FFT. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●August 9, 20132013-08-09
Randy Yates <yates@digitalsignallabs.com> writes:> Randy Yates <yates@digitalsignallabs.com> writes: > >> "EthanHarvard" <98300@dsprelated> writes: >> >>> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I >>> want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 >>> through 64 (total 65 points)? >>> >>> And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I >>> consider 64 through 128 (total 65 points)? >> >> Yes. > > Sorry, I didn't notice your +1's, so no, that's not right. > > The first half would be 0 to 63; second half 64 to 128 (65 points), if > you wanted to catch the last term at Fs/2. Most people don't plot that > last point and just take 0 to N/2 - 1 for an even N-point FFT.Well I have to correct my correction. What you stated is correct, given you want 0 to 2000 and 2000 through 4000. The point at 2000 is then plotted twice. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●August 9, 20132013-08-09
Randy Yates <yates@digitalsignallabs.com> wrote:> Randy Yates <yates@digitalsignallabs.com> writes: >> Randy Yates <yates@digitalsignallabs.com> writes:>>> "EthanHarvard" <98300@dsprelated> writes:>>>> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I >>>> want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 >>>> through 64 (total 65 points)?(snip)> Well I have to correct my correction. What you stated is correct, given > you want 0 to 2000 and 2000 through 4000. The point at 2000 is then > plotted twice.Seems that there is no mention of windowing. 256 is pretty small with the speed of computers today. -- glen
Reply by ●August 9, 20132013-08-09
On Friday, August 9, 2013 2:37:47 PM UTC-4, glen herrmannsfeldt wrote:> Randy Yates <yates@digitalsignallabs.com> wrote: > > > Randy Yates <yates@digitalsignallabs.com> writes: > > >> Randy Yates <yates@digitalsignallabs.com> writes: > > > > >>> "EthanHarvard" <98300@dsprelated> writes: > >I figured once the OP sorts out his application, then we can talk about sample sizes and windows. I didn't want to confuse matters too much early on. Clay> > >>>> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I > > >>>> want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 > > >>>> through 64 (total 65 points)? > > > > (snip) > > > > > Well I have to correct my correction. What you stated is correct, given > > > you want 0 to 2000 and 2000 through 4000. The point at 2000 is then > > > plotted twice. > > > > Seems that there is no mention of windowing. > > > > 256 is pretty small with the speed of computers today. > > > > -- glen
Reply by ●August 9, 20132013-08-09
glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:> Randy Yates <yates@digitalsignallabs.com> wrote: >> Randy Yates <yates@digitalsignallabs.com> writes: >>> Randy Yates <yates@digitalsignallabs.com> writes: > >>>> "EthanHarvard" <98300@dsprelated> writes: > >>>>> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I >>>>> want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 >>>>> through 64 (total 65 points)? > > (snip) > >> Well I have to correct my correction. What you stated is correct, given >> you want 0 to 2000 and 2000 through 4000. The point at 2000 is then >> plotted twice. > > Seems that there is no mention of windowing.I don't do windows. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●August 9, 20132013-08-09
"EthanHarvard" <98300@dsprelated> writes:> I have an audio signal at 8 kHz sampling rate. I take 256 point FFT. If I > want to plot frequency from 0 Hz to 2000 Hz, should I consider FFT points 0 > through 64 (total 65 points)? > > And I I want to plot spectrogram of upper half (2 kHz - 4 kHz), should I > consider 64 through 128 (total 65 points)?To the group (as well as you, Ethan), This simple question brings up a couple of points I think are right but I'd like clarification: 1. The N-point DFT result at N/2 is always unreliable, right? E.g., sin(2*pi*n*Ts*(Fs/2)) = sin(pi*n) = 0 2. (Nota Bene: I'm thinking in the analytical domain, so please don't bring up practical issues.) If the time sequence that is input to this DFT originated from a continuous-time signal that was sampled ideally so that Fs / 2 > Fmax (note the strict inequality), then the N/2 term should always be zero. It seems weird that I haven't really thought about the N/2 result this way before (or if I did, I've forgotten!). -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Reply by ●August 9, 20132013-08-09
On 8/9/13 2:43 PM, Randy Yates wrote:> > This simple question brings up a couple of points I think are > right but I'd like clarification: > > 1. The N-point DFT result at N/2 is always unreliable, > right? E.g., > > sin(2*pi*n*Ts*(Fs/2)) = sin(pi*n) > = 0 >i wouldn't use the word "unreliable". i would say, that for real signals, frequency components at Nyquist cannot be fully represented with unambiguous amplitude and phase.> 2. (Nota Bene: I'm thinking in the analytical domain, so please don't > bring up practical issues.) If the time sequence that is input to this > DFT originated from a continuous-time signal that was sampled ideally > so that Fs / 2> Fmax (note the strict inequality), then the N/2 term > should always be zero.only if your DFT input data (that is bandlimited to below Nyquist) is periodic with period N. if you have arbitrary input (whether it's real or complex) that is bandlimited to below Nyquist and you yank out N samples from that input and pass it to the DFT, you can certainly get something non-zero for X[N/2]. if the input is real, then the imaginary part of X[N/2] is zero.> It seems weird that I haven't really thought about the N/2 result this > way before (or if I did, I've forgotten!).that X[N/2] thing has always bothered me when i consider bandlimited interpolation of real and periodic discrete signals (x[n] = x[n+N] and N is even). -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."






