DSPRelated.com
Forums

FFT and Sine Waves Question

Started by Raeldor August 26, 2011
Hi All,

I was doing some experimenting and was wondering if someone could
explain my results.  I have a pure sine wave at 1000hz generated into
a wave file.  I also have some FFT code to produce a spectrograph.  If
I run the wave file through the FFT, the spectrograph has one white
line running through it (across time), which is what I would expect.
HOWEVER, if I play the same sine wave and record it through a
microphone and then run that sample through, I get what look like
(possibly) harmonics, but certainly some strong lines consistently
running across above the 1000hz mark.

Can anyone explain what may be going on here.  I'd like to do a little
more research, but it's hard to know at this point what I should be
google'ing for.

Thanks
Rael
On Aug 25, 10:18&#4294967295;pm, Raeldor <rael...@gmail.com> wrote:
> Hi All, > > I was doing some experimenting and was wondering if someone could > explain my results. &#4294967295;I have a pure sine wave at 1000hz generated into > a wave file. &#4294967295;I also have some FFT code to produce a spectrograph. &#4294967295;If > I run the wave file through the FFT, the spectrograph has one white > line running through it (across time), which is what I would expect. > HOWEVER, if I play the same sine wave and record it through a > microphone and then run that sample through, I get what look like > (possibly) harmonics, but certainly some strong lines consistently > running across above the 1000hz mark. > > Can anyone explain what may be going on here. &#4294967295;I'd like to do a little > more research, but it's hard to know at this point what I should be > google'ing for. > > Thanks > Rael
I did some more testing, and it seemed the extra lines were at harmonic frequencies, so I lowered the volume on the sample playing into the mic and the harmonics lessened. Could this be clipping cutting off the top of the sine wave, which is producing harmonics? Thanks Rael
>Hi All, > >I was doing some experimenting and was wondering if someone could >explain my results. I have a pure sine wave at 1000hz generated into >a wave file. I also have some FFT code to produce a spectrograph. If >I run the wave file through the FFT, the spectrograph has one white >line running through it (across time), which is what I would expect. >HOWEVER, if I play the same sine wave and record it through a >microphone and then run that sample through, I get what look like >(possibly) harmonics, but certainly some strong lines consistently >running across above the 1000hz mark. > >Can anyone explain what may be going on here. I'd like to do a little >more research, but it's hard to know at this point what I should be >google'ing for. > >Thanks >Rael >
What your spectrograph is telling you is that your wave file contains a perfect sine wave (no harmonics) but also that your reproduced and recorded sine wave is no longer a perfect sine wave. If you open up your recorded wave file in some editor and zoom in on a the waveform you can probably also see that it is not a perfect sine wave. Your recording setup may contain all or some of the following steps: wave file -> DAC (soundcard) -> amp -> speaker -> room -> mic -> mic amp -> ADC -> wave file Each step will add some distortion to your sine wave that can show up as harmonics. Maybe your speaker is not operating in it linear range or maybe the amp produces some distortion. Maybe our spectrograph can tell you the magnitude of the strongest harmonic relative to the fundamental. By the way, is your first harmonic at 2000Hz or at 3000Hz? just curious.
On Aug 26, 12:23&#4294967295;am, "niarn" <niaren9@n_o_s_p_a_m.gmail.com> wrote:
> >Hi All, > > >I was doing some experimenting and was wondering if someone could > >explain my results. &#4294967295;I have a pure sine wave at 1000hz generated into > >a wave file. &#4294967295;I also have some FFT code to produce a spectrograph. &#4294967295;If > >I run the wave file through the FFT, the spectrograph has one white > >line running through it (across time), which is what I would expect. > >HOWEVER, if I play the same sine wave and record it through a > >microphone and then run that sample through, I get what look like > >(possibly) harmonics, but certainly some strong lines consistently > >running across above the 1000hz mark. > > >Can anyone explain what may be going on here. &#4294967295;I'd like to do a little > >more research, but it's hard to know at this point what I should be > >google'ing for. > > >Thanks > >Rael > > What your spectrograph is telling you is that your wave file contains a > perfect sine wave (no harmonics) but also that your reproduced and recorded > sine wave is no longer a perfect sine wave. If you open up your recorded > wave file in some editor and zoom in on a the waveform you can probably > also see that it is not a perfect sine wave. Your recording setup may > contain all or some of the following steps: > > wave file -> DAC (soundcard) -> amp -> speaker -> room -> mic -> mic amp -> > ADC -> wave file > > Each step will add some distortion to your sine wave that can show up as > harmonics. Maybe your speaker is not operating in it linear range or maybe > the amp produces some distortion. Maybe our spectrograph can tell you the > magnitude of the strongest harmonic relative to the fundamental. By the > way, is your first harmonic at 2000Hz or at 3000Hz? just curious.
Thank you for the explanation, I guess I was just surprised how different they looked. Yes, the first harmonic was definitely at 2000hz. Thanks Rael
On Aug 26, 9:25&#4294967295;am, Raeldor <rael...@gmail.com> wrote:

> > > >I was doing some experimenting and was wondering if someone could > > >explain my results. &#4294967295;I have a pure sine wave at 1000hz generated into > > >a wave file. &#4294967295;
> &#4294967295;Yes, the first harmonic was definitely at 2000hz.
Wouldn't that be the second harmonic? or has audio terminology changed from earlier times? Jerry? --Dilip Sarwate
On Aug 26, 8:05&#4294967295;am, dvsarwate <dvsarw...@yahoo.com> wrote:
> On Aug 26, 9:25&#4294967295;am, Raeldor <rael...@gmail.com> wrote: > > > > > > >I was doing some experimenting and was wondering if someone could > > > >explain my results. &#4294967295;I have a pure sine wave at 1000hz generated into > > > >a wave file. &#4294967295; > > &#4294967295;&#4294967295;Yes, the first harmonic was definitely at 2000hz. > > Wouldn't that be the second harmonic? &#4294967295;or has > audio terminology changed from earlier times? > Jerry? > > --Dilip Sarwate
Oh No! The dreaded "Do we start counting with zero or one?" topic again! Dale B. Dalrymple
On 8/26/2011 2:07 PM, dbd wrote:
> On Aug 26, 8:05 am, dvsarwate<dvsarw...@yahoo.com> wrote: >> On Aug 26, 9:25 am, Raeldor<rael...@gmail.com> wrote: >> >> >> >>>>> I was doing some experimenting and was wondering if someone could >>>>> explain my results. I have a pure sine wave at 1000hz generated into >>>>> a wave file. >>> Yes, the first harmonic was definitely at 2000hz. >> >> Wouldn't that be the second harmonic? or has >> audio terminology changed from earlier times? >> Jerry? >> >> --Dilip Sarwate > > Oh No! The dreaded "Do we start counting with zero or one?" topic > again!
Oh No indeed! "First harmonic" is synonymous with "fundamental". (The zeroth harmonic is DC.) If Raeldor meant "the first harmonic not in the original", that would also be correct. Raeldor: The lowest distortion produce being at 2 KHz shows that the distortion is asymmetric. Symmetric distortion implies the presence of only odd harmonics, 1st, 3rd, 5th, etc. Jerry -- Engineering is the art of making what you want from things you can get.
On 8/26/11 2:34 PM, Jerry Avins wrote:
> On 8/26/2011 2:07 PM, dbd wrote: >> On Aug 26, 8:05 am, dvsarwate<dvsarw...@yahoo.com> wrote: >>> >>> Wouldn't that be the second harmonic? or has >>> audio terminology changed from earlier times? >>> Jerry? >>> >> >> Oh No! The dreaded "Do we start counting [from] zero or one?" topic >> again! > > Oh No indeed! "First harmonic" is synonymous with "fundamental". (The > zeroth harmonic is DC.) If Raeldor meant "the first harmonic not in the > original", that would also be correct. >
it's more like counting from one or from two. there are some folks (usually musicians) that count the "first overtone" as being what we call the second harmonic. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Aug 26, 1:34&#4294967295;pm, Jerry Avins <j...@ieee.org> wrote:

> > Raeldor: The lowest distortion produce being at 2 KHz shows that the > distortion is asymmetric. Symmetric distortion implies the presence of > only odd harmonics, 1st, 3rd, 5th, etc. >
OK, now I am confused even further. If the input is x(t) and the output is x(t) + 0.002[x(t)]^2, I would have thought that the *distortion* would be called symmetric in the sense that 0.002x^2 is an even function. But when x(t) = cos(wt), the output is cos(wt) + 0.002 cos^2(wt) = 0.002 + cos(wt) + 0.002 cos(2wt), that is, the *distortion* was creating only the zeroth harmonic and the second harmonic! But this is in direct contradiction to Jerry's assertion that symmetric distortion creates only odd harmonics. So, somewhere I must be misunderstanding or maybe miscounting. Or did Jerry mean to write that symmetric distortion creates only odd overtones in the sense of rb-j's statement that musicians call the second harmonic the first overtone? --Dilip Offbyone
dvsarwate <dvsarwate@yahoo.com> wrote:

(snip)
>> &#4294967295;Yes, the first harmonic was definitely at 2000hz.
> Wouldn't that be the second harmonic? or has > audio terminology changed from earlier times?
Yes is should be the second harmonic. This is mostly described in the wikipedia page Harmonic_series_(music). It is complicated by the fact that in many musical instruments the higher modes (harmonics) are often not exact integer multiples. The music term "partial" is meant to include the case of non-integer multiples, but uses a numbering system such that the first partial is the first one above the fundamental. It seems more confusing for "overtone". As far as I can tell, in music the fundamental is not the first overtone, but in EE (crystal oscillator modes) it is. -- glen