DSPRelated.com
Forums

FFT of non-integer waveform

Started by Ross Clement (Email address invalid - do not use) February 1, 2006
Hi everyone. Suppose I have a sound sample digitised at say 44.1khz.
Say that I have identified a single cycle of a waveform and wish to
perform a fft so that I can understand the spectral content of the
waveform. What happens if I believe that the waveform starts in between
two of the samples and ends between another two samples. How do I then
use a discrete fourier transform to measure the spectral content. One
potential method is to ignore the non-integer starts, and fourier
transform the waveform using the nearest samples from the beginning and
the end. Another simple method would be to resample the waveform to a
much higher sampling rate so that I at least get nearer to the true
start and finish of the waveform.

Are there any techniques for this kind of problem?

Cheers,

Ross-c

Ross Clement (Email address invalid - do not use) wrote:
> Hi everyone. Suppose I have a sound sample digitised at say 44.1khz. > Say that I have identified a single cycle of a waveform and wish to > perform a fft so that I can understand the spectral content of the > waveform. What happens if I believe that the waveform starts in between > two of the samples and ends between another two samples. How do I then > use a discrete fourier transform to measure the spectral content. One > potential method is to ignore the non-integer starts, and fourier > transform the waveform using the nearest samples from the beginning and > the end. Another simple method would be to resample the waveform to a > much higher sampling rate so that I at least get nearer to the true > start and finish of the waveform. > > Are there any techniques for this kind of problem?
I don't fully understand the question, but there is this thing called non-integer time delay estimation. If you have a reference recording of the waveform available, you could examine the phase of the cross spectrum between the reference and the recorded data. See Bendat & Piersol: Random Data, 4th ed., Wiley 2000. Without the reference it might become a lot harder. Rune
"Ross Clement (Email address invalid - do not use)" <clemenr@wmin.ac.uk> 
wrote in message 
news:1138808337.727873.120020@g49g2000cwa.googlegroups.com...
> Hi everyone. Suppose I have a sound sample digitised at say 44.1khz. > Say that I have identified a single cycle of a waveform and wish to > perform a fft so that I can understand the spectral content of the > waveform. What happens if I believe that the waveform starts in between > two of the samples and ends between another two samples. How do I then > use a discrete fourier transform to measure the spectral content. One > potential method is to ignore the non-integer starts, and fourier > transform the waveform using the nearest samples from the beginning and > the end. Another simple method would be to resample the waveform to a > much higher sampling rate so that I at least get nearer to the true > start and finish of the waveform. > > Are there any techniques for this kind of problem? >
There are a number of comments possible: If you have a well-sampled waveform then presumably you can reconstruct it to a continuous waveform. You mentioned interpolation already. This raises the question: "How do you know that the waveform starts if you don't have a sample at the beginning?" If the waveform is of any reasonable length, then the placement of the beginning and ending samples aren't very important. This is related to the ability to interpolate/reconstruct. If you have lots of samples then the Fourier Transform is pretty well determined. Fred Fred
Ross Clement (Email address invalid - do not use) wrote:
> Hi everyone. Suppose I have a sound sample digitised at say 44.1khz. > Say that I have identified a single cycle of a waveform and wish to > perform a fft so that I can understand the spectral content of the > waveform.
First there is the problem of the meaning of spectral content of a non-repeating single cycle of a waveform. I'll assume you mean the spectral content of a hypothetical wavefrom as if this single cycle was repeated.
> What happens if I believe that the waveform starts in between > two of the samples and ends between another two samples. How do I then > use a discrete fourier transform to measure the spectral content. One > potential method is to ignore the non-integer starts, and fourier > transform the waveform using the nearest samples from the beginning and > the end.
This should give identical magnitude results if the waveform is of integer length in samples and bandlimited and the same length as the FFT. The identical sample offset at the beginning and end will change the FFT phase result slightly but linearly.
> Another simple method would be to resample the waveform to a > much higher sampling rate so that I at least get nearer to the true > start and finish of the waveform.
This method might give clearer results if the waveform is of a non-integer length in samples, and if your resampler introduces less error than would the spectral aliasing incurred by an FFT length that is not an exact multiple of the waveform period. I've done this to resample waveforms to a power of 2 in length when that was the only fast FFT routine handy. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
in article 1138808337.727873.120020@g49g2000cwa.googlegroups.com, Ross
Clement (Email address invalid - do not use) at clemenr@wmin.ac.uk wrote on
02/01/2006 10:38:

> Hi everyone. Suppose I have a sound sample digitised at say 44.1khz. > Say that I have identified a single cycle of a waveform and wish to > perform a fft so that I can understand the spectral content of the > waveform.
that is, you want the Fourier coefficients of that single cycle periodically extended, right? this assumes you have some sort of pitch detector that identifies the period length of the periodic or quasi-periodic waveform, right?
> What happens if I believe that the waveform starts in between > two of the samples and ends between another two samples? How do I then > use a discrete fourier transform to measure the spectral content? One > potential method is to ignore the non-integer starts, and fourier > transform the waveform using the nearest samples from the beginning and > the end.
yeah, but you'll get errors.
> Another simple method would be to resample the waveform to a > much higher sampling rate
and then polynomial or even just linearly interpolate in between those more closely spaced samples.
> so that I at least get nearer to the true > start and finish of the waveform. > > Are there any techniques for this kind of problem?
resample to a higher rate and then interpolate in between the newer, more closely spaced (in time) samples. if you upsample by a factor of 512 (now you don't have to evaluate each of the new 512 samples per input sample, you only need to do it for each of the N samples going into your N-point FFT), linear interpolation should be fine. if this is for musical tone application, you might want to take a look at http://www.musicdsp.org/files/Wavetable-101.pdf . -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Thanks to everyone who replied on this thread. Not having the time to
give a detailed point by point followup with proper referencing...

The cycles of interest are from a longer waveform. Hence I can look at
the samples both to the left and right of my sample.

The waveform is bandpass filtered and should be close to a sine wave.
hence a cycle starts with a zero crossing, a maxima follows, another
zero crossing, a minima, and a final zero crossing. The positions of
the starting and ending zero crossing can be reasonably accurately
estimated by curve fitting in the neighbourhood of the crossing. The
signals are synthetic data and hence I know everything there is to know
about the signal. I'm interested in measuring the effects on measured
spectrum of distortion of the sine wave due to constantly changing
pitch and amplitude parameters.

Cheers,

Ross-c

Ross Clement (Email address invalid - do not use) wrote:
> Thanks to everyone who replied on this thread. Not having the time to > give a detailed point by point followup with proper referencing... > > The cycles of interest are from a longer waveform. Hence I can look at > the samples both to the left and right of my sample. > > The waveform is bandpass filtered and should be close to a sine wave. > hence a cycle starts with a zero crossing, a maxima follows, another > zero crossing, a minima, and a final zero crossing. The positions of > the starting and ending zero crossing can be reasonably accurately > estimated by curve fitting in the neighbourhood of the crossing. The > signals are synthetic data and hence I know everything there is to know > about the signal. I'm interested in measuring the effects on measured > spectrum of distortion of the sine wave due to constantly changing > pitch and amplitude parameters.
A cycle can start anywhere; a minimum, a maximum, or anywhere between. A zero crossing is only one of those in-between points. Only the duration matters. 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;
Yes. I identify the minimums and maximums as well and fit parobolas to
them to improve accuracy. That means that I was identifying 0, pi/2,
pi, 3*pi/2, and 2pi locations on the wave. I was trying to use
search-based optimisation techniques to both identify pi/4, 3*pi/4,
5*pi/4, and 7*pi/4 as well while simultaneously optimising my estimates
of where the minima and maxima of the pure sine wave (if there had been
no varying amplitude) were. But my results were soundly negative. My
optimisation technique found models of the frequency variations that
fitted the observed waveform much much better than just predicting that
pi/4 was half way between 0 and pi/2 and that the observed maxima was
the true maxima etc. However, those models had no relation to the true
variations in amplitude and frequency used when generating the
synthetic data.

Cheers,

Ross-c

PS: I should have replied to Jerry's comment more directly. I wasn't
saying that the zero-crossing was the official definition of the start
of any waveform. This thinking is just what I (and my programs) have
adopted to ease thinking about my current problem.

Cheers,

Ross-c

Ross Clement (Email address invalid - do not use) wrote:
> PS: I should have replied to Jerry's comment more directly. I wasn't > saying that the zero-crossing was the official definition of the start > of any waveform. This thinking is just what I (and my programs) have > adopted to ease thinking about my current problem.
Zero crossings are labile. A little noise or small added signal can shift them a lot. The amplitude of the computed result can very greatly from the original if the phases but not the amplitudes of the computed components vary. (For an extreme case, compare sin(kt) + sin(3kt) to sin(kt) - sin(3kt). 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;