DSPRelated.com
Forums

VC33 Audio spectrum analyzer noise and/or harmonics

Started by slas...@gmail.com August 15, 2005
Hi all,

I'm using the VC33 University DSK to sample sound and display a frequency spectrum. I have created some code mostly made up of existing code included with the VC33 DSK CDROM. The code uses a fairly simple RINT routine to sample the sound into an array. After sampling the sound I'm running an FFT/Windowing routine based on fft256b.asm. A graphpoint is setup after windowing to send the data to my PC using the DSK3DW.EXE program.

With some simple test sounds (like picking a string on a guitar, or using a reference sound from my guitar tuner) my FFT results show the first hump at a low valued frequency bin but a there are also other humps throughout the frequency spectrum. With such simple sounds, i'd expect maybe one or two humps for some harmonics, but not the >10 that I'm seeing now. Has anybody seen this behavior with the fft256b.asm FFT? details and code below...

thx!
Sean

I'm running my code with a 12.207kHz sampling rate and 256 samples. This should give me fft output with a frequency resolution of ~47Hz and a nyquist frequency of 6.104kHz. The output graph is setup to only show the first half of the fft output (128 points).

To test my code, I have a Korg CA-30 guitar tuner that outputs an audio test tone. It says this tone is 440Hz (A4). When I turn on this tone, the fft output shows the biggest peak at the 15th location in the array corresponding to about 705hz (maybe I've misunderstood what the guitar tuner is producing...). My big concern is the other peak of a slightly greater amplitude at the 114th location in the array. The peak seems like it could be some kind of mirror. There are also other peaks of decreasing value as you get closer to the 64th location in the array (the center) for a total quantity of 14 peaks from beginning to end. When I turn off the guitar tuner, the peaks disappear and the display returns to a base 'background noise' level. All peaks were about 5-7 frequency bins in width from trough to trough, which is also wider than I expected Maybe I've got a bit of spectral leakage, but I wouldn't expect it to be this dramatic. I confirmed this 256 point FFT is mirrored around the center bin, so reading the first 128 samlpes seems to be the right thing to do.

I tried 'open High e' (high e is 329.6hz) on my guitar and there were still multiple peaks decreasing in amplitude towards the center, but now they were wider, not as clean and had a 'W' shaped peak instead of a nice hump like the test tone. Two main peaks almost identical in amplitude were located at frequency bins 3 and 10. At bin 7 there is a consistent trough/mini W peak which happens to correspond to 330hz. Cool?!? Maybe harmonics can explain all the W shaped peaks, but I still don't understand the mirroring. I tried the guitar because I don't know if my tuner is generating an audio square or sawtooth type wave which could possibly cause some funny results.

man, I'd love to just include a couple screenshots...

I'm still trying to figure out how to use LRCIN to decouple the left microphone samples from the right microphone samples. Could this be the cause of the peak at the other end of the array? How does sampling work if you don't divide the samples into left and right explicitly?

As you can see, I'm a newbie to this stuff. Any sharing of like experiences sampling simple audio sounds into an fft would be greatly appreciated. I've included my code below in case anything wasn't clear.

One other thing... I'm running the test tones and simple notes to try to understand the DSP/FFT technology, but my goal is to detect a more 'transient' sound. Maybe the kind of sound you'd hear if you let a piece of paper touch the moving blades of a table fan... tack, tack, tack, tack or buzzzzz. Is this crazy? Can an FFT resolve such sounds?

alright, one more question I can't figure out, why in GETADC routine is there a lsh -16 and a ash +16. Doesn't this just elimate valuable resolution from the measurements???

If you're a newbie like me and need quick code to get your audio spectrum analyzer up and running, this is a decent starting point. Assemble and load it up then Debug->animate BP and it will run on its own. But don't animate for more than a minute or two, my old laptop freaked out when i left it animating for an hour. And the sound on the output is just a ramp signal, there's no real time audio feedback.

thx, and sorry for being soooo long :) .include



Hi

You have a number of good questions, and seem to be figuring this out mostly on your own.  This is great, because you are learning.  I cant spend tons of time on eveything you asked, but I do have some thoughts.

As you have surmised, a 256 point FFT with 11 Khz sampling will have a fairly coarse frequency resolution.  This is probably because you noticed that the debugger graphing feature is moving unpacked FFT data.  The DSK3WIN3.EXE demo supports up to 8K stereo FFT size, but also packs the data to be displayed into 8 bit log values which would be 4x faster for just the data.  If the debugger is showing additional data, this too subtracts from the available bandwidth. The trick is to not view lots of data at one time.

If your Korg tuner seems to be working with your guitar, I would expect the frequency discrepancy is in the DSP code.  When I use the spectrum analyzer demo, frequencies are dead on.  Since your peak is not at 440/2 or 440*2, one of my suspicions would be the TCLK0 master clock.  If you had simply mixed the Left and Right values this would double your data samples, halving the measured frequency, but that ratio is off.

If you dont have an oscilloscope (a second DSK would also work), try lowering Fs yet again.  This will drop the LRCIN rate well into the audible range, which you could then listen to with a headphone.  Keep in mind that you cant load these signals very much, but if you add a series 1K resistor and 1uF cap, this signal should be quite audible (the 1K resistor and AC coupling will limit the driver current to +/-1.6V/1K or +/-1.6ma).

The PCM3003 has a pretty clean ADC.  If you are seeing harmonics, you might be over driving the input (I think +/-2V is clipping), looking at a sine shaped triangle wave (dirty), or have some kind of grounding loop, but this is usually a 60Hz problem. 
You will also find that guitars have loads of harmonics compared to sine waves.  If there is a clipping problem it should be pretty obvious as the signal decays with time. 

Another point you made is that you dropped Fs to 11Khz.  This may effect the input aliasing filter which I know is not  perfect.  The bottom line is that 'perfect' requires infinite rejection, and this is impossible.  My recollection was that the PCM3003 out of band rejection was pretty good at 48Khz (see the data sheet), but I dont have any recollection of what happens when FsK.  It is quite possible that some fudging is going on.

If you keep poking around in the code and examples you will also find both 16b and 20b GETADC routines.  In particular, look in PCM3003.ASM.  This is the codec support code for FFT_3003.ASM, which is the DSP code used with the FFT demo DSK3WIN3.  There are also C versions.  Oh... and by the way, if the jumper settings on the DSK need to match!  The jumpers tell the codec how to format the data.  The DSP serial port is also just as happy to clock in data.  If the two do not match you will get some funny results!

At some point you will also likely want logarithmic scaling and this is simple beyond belief when you happen to be using a floating CPU.  There are several sections in the help file that cover this in greater detail.  You may want to look into the FFT_RR5 example.

Anyhow, as I said, I dont have tons of time to answer everything in depth.

Oh yes... it is quite possible to find and lock onto the 'buzzing' you asked about.  That application is quite a bit more advanced and was not part of the DSK package.  Do you have anything you would like to trade for that kind of help?  By the way, thats a shameless plug on my part!
 

Hope this helps
Best regards,

Keith Larson
DSP and Analog Consultant
Lincoln, Ma 01773


s...@gmail.com wrote:
Hi all,

I'm using the VC33 University DSK to sample sound and display a frequency spectrum.  I have created some code mostly made up of existing code included with the VC33 DSK CDROM.  The code uses a fairly simple RINT routine to sample the sound into an array.  After sampling the sound I'm running an FFT/Windowing routine based on fft256b.asm.  A graphpoint is setup after windowing to send the data to my PC using the DSK3DW.EXE program.

With some simple test sounds (like picking a string on a guitar, or using a reference sound from my guitar tuner) my FFT results show the first hump at a low valued frequency bin but a there are also other humps throughout the frequency spectrum.  With such simple sounds, i'd expect maybe one or two humps for some harmonics, but not the >10 that I'm seeing now.  Has anybody seen this behavior with the fft256b.asm FFT? details and code below...

thx!
Sean

I'm running my code with a 12.207kHz sampling rate and 256 samples.  This should give me fft output with a frequency resolution of ~47Hz and a nyquist frequency of 6.104kHz.  The output graph is setup to only show the first half of the fft output (128 points).

To test my code, I have a Korg CA-30 guitar tuner that outputs an audio test tone. It says this tone is 440Hz (A4).  When I turn on this tone, the fft output shows the biggest peak at the 15th location in the array corresponding to about 705hz (maybe I've misunderstood what the guitar tuner is producing...).  My big concern is the other peak of a slightly greater amplitude at the 114th location in the array. The peak seems like it could be some kind of mirror.  There are also other peaks of decreasing value as you get closer to the 64th location in the array (the center) for a total quantity of 14 peaks from beginning to end.  When I turn off the guitar tuner, the peaks disappear and the display returns to a base 'background noise' level.  All peaks were about 5-7 frequency bins in width from trough to trough, which is also wider than I expected  Maybe I've got a bit of spectral leakage, but I wouldn't expect it to be this dramatic.  I confirmed this 256 point FFT is mirrored around the center bin, so reading the first 128 samlpes seems to be the right thing to do.

I tried 'open High e' (high e is 329.6hz) on my guitar and there were still multiple peaks decreasing in amplitude towards the center, but now they were wider, not as clean and had a 'W' shaped peak instead of a nice hump like the test tone.   Two main peaks almost identical in amplitude were located at frequency bins 3 and 10.  At bin 7 there is a consistent trough/mini W peak which happens to correspond to 330hz.  Cool?!?  Maybe harmonics can explain all the W shaped peaks, but I still don't understand the mirroring.  I tried the guitar because I don't know if my tuner is generating an audio square or sawtooth type wave which could possibly cause some funny results.                     

man, I'd love to just include a couple screenshots...

I'm still trying to figure out how to use LRCIN to decouple the left microphone samples from the right microphone samples.   Could this be the cause of the peak at the other end of the array?  How does sampling work if you don't divide the samples into left and right explicitly?

As you can see, I'm a newbie to this stuff.  Any sharing of like experiences sampling simple audio sounds into an fft would be greatly appreciated.  I've included my code below in case anything wasn't clear.

One other thing... I'm running the test tones and simple notes to try to understand the DSP/FFT technology, but my goal is to detect a more 'transient' sound.  Maybe the kind of sound you'd hear if you let a piece of paper touch the moving blades of a table fan... tack, tack, tack, tack or buzzzzz.  Is this crazy?  Can an FFT resolve such sounds?

alright, one more question I can't figure out, why in GETADC routine is there a lsh -16 and a ash +16.  Doesn't this just elimate valuable resolution from the measurements???

If you're a newbie like me and need quick code to get your audio spectrum analyzer up and running, this is a decent starting point.  Assemble and load it up then Debug->animate BP and it will run on its own.  But don't animate for more than a minute or two, my old laptop freaked out when i left it animating for an hour.  And the sound on the output is just a ramp signal, there's no real time audio feedback. 
 
thx, and sorry for being soooo long :)         .include