Audio Spectrum Analyzer.
lyassa
Posts: 52
I want to build an audio spectrum analyzer. I couldn't find a FFT object in OBEX, and it doesn't seem easy to roll my own. Any advice how to go about building a simple spectrum analyzer using the Propeller?
Thanks.
Thanks.
Comments
In the mean time have a search for heater_fft in this forum.
Google search on "fft heater www.parallax.com"
produces some results
Jim
http://forums.parallax.com/showthread.php?96099-Propeller-Application-DEMO-Spectrum-Analyzer-%28for-Audio%29
... and it works really well when I feed it a sine or square wave from a signal generator. However, it doesn't work well when I feed it signal from a guitar, for example. Does anyone know if the routine works only with "pure" fixed frequency signal or should it work also with "mixed" signal like guitar signal?
With lots of spectral bands the FFT is going to win easily on performance though.
Thread: http:// http://forums.parallax.com/showthread.php?96099-Propeller-Application-DEMO-Spectrum-Analyzer-%28for-Audio%29
Leads to dead end: http://members.cox.net/brookhaven-north/Parallax/PropellerSpectrumAnalyzerforAudio.html
Best way to google search the forums is:
site:forums.parallax.com heater_fft
http://www.alcatel-lucent.com/bstj/vol48-1969/articles/bstj48-3-501.pdf
ForumGeneral ForumsPropeller Chip Heater's Fast Fourier Transform.
Jim
Yes, the link in the post is not functional, but the attachments in that same post works. I downloaded "TV - Audio Spectrum Analyzer.zip", modified it a little bit to detect certain frequencies, e.g. 1khz, 2khz from the signal generator (this part works well). Then tried to detect the musical notes frequencies, and this is the part that is not working.
Did you put the output of the guitar through a preamp first?
I need to use the "Wayback" machine to retrieve some of the things I was hosting.
The word document is essentially what was being hosted on the page...
http://forums.parallax.com/attachment.php?attachmentid=48409&d=1185537374
Aside from that, the Audio Spectrum Analyzer should work better after amplification, but consider that for every frequency present in the signal you will have a distribution loss to contend with. i.e. a single frequency present will provide the best 100% signal detection ... two frequencies 50% ... three 33.3% ... four 25% ... etc... 20%, 17%, 14% ....
Yes I do. I am using LM324, powering it from the 3.3V and getting output ranging from 0 to 2v. I was hoping to get output of 0V to 3.3V since LM324 is rail to rail. The signal gets distorted wen I increase the gain. I still need to spend some time on the amp circuit.
So may be I do not have adequate amplification (output is 0V to 2V). Thanks a lot for the tip " two frequencies 50% ... three 33.3% ...", I didn't know that. I was looking for values > 50% regardless how many notes are played at once. Will take this info in consideration now.
The LM324 is not a rail-to-rail amplifier. The input and output common-mode ranges run from 0 to Vdd - 1.5V. You have to be careful not to amplify your signal too much, else you'll get peak clipping, leading to spurious harmonics in your spectral analysis.
-Phil
But running from 3.3V with a virtual earth of 1.65V I think you will only be able to get a signal from 1.5V to 1.8V.
A CA3140 can go rail to rail, but I think min supply voltage is 4V. So you could run it from 5V and create a virtual earth of 1.65V. If all of that is a bit confusing maybe post a schematic because there are many ways of creating distorted waveforms if op amps are not used correctly
I am using the circuit below. I replaced R3 and R4 by a potentiometer, that allows me to shift the output so that I do not have a dc component on the output. I also removed C2 and R1 and replaced the mic by the signal generator. I am connecting the output directly to the Propeller. I will try it with 5V supply and will post the result.
One concept very useful with op amps and a single rail supply is a 'virtual earth'. For the propeller 1.65V would be the right voltage. So whatever input you have needs to be biased to 1.65V. It might be already if whatever made the signal was supplied by 3.3V (eg another propeller). Actually you might not even need an amplifier if the signal was, say, 1V peak to peak. Just change the bias so it sits in the middle of the propeller range. A 1uF and a couple of 10k resistors could do that. And you might need to attenuate rather than amplify the signal - if so, we can do that with resistors rather than with an op amp.
I'm hoping with enough information we won't need a CRO. I got away with building audio circuits for 20 years without a CRO and it can be possible - just need to think about what the voltages are and whether you are introducing distortion by amplifying things too much.
The signal is 50mv peak to peak. Fortunately I have a signal generator and an oscilloscope so I can see if a distortion is introduced. I adjust the variable resistors to stay away from any distortion and to make the output vary between 0V and 2V (2V for now, will be 3.5V when I supply the op amp with 5V). After things looks good with the signal generator, then I use a guitar as an audio signal source of mixed frequencies (about 50mv peak to peak). So in brief, I am mapping (-25mV to +25mV) into (0V to 3.5V). That is a gain of 70.
The LM324 is not rail-to-rail - the inputs and outputs go to Vcc-1.5 or so only. Power it from 5V and it should deal with inputs from 0 to 3.3V happily though.
Also most opamp's perform poorly near the limits of voltage (gain reduces, bandwidth reduces, output current drive drops by orders of magnitude - all rail-to-rail opamps are a compromise alas, but Analog Devices seem to make a good range to choose from - I'd always choose 5V over 3V3 for an opamp supply if I could, a lot more choice of devices.