Go Down

Topic: 16 Sample 0-20,000 hz Audio Spectrum Analyzer Help  (Read 2099 times) previous topic - next topic

circuitdh

Hello, i am in need of help in making a 0-20,000 hz Audio Spectrum Analyzer on Arduino.  I'll start by giving some background info.  This analyzer will be used in a 16x4x12 (LxWxH) LED Cube, which I have already almost completed.  The hard part for me is getting the code right for the analyzer.  I can easily change the results of the analyzer into LED patterns, but I am struggling with generating the prospectus array.   
 - To say it simply, I need help making some code that will convert  a phone audio jack's signal into an array of 16 numbers (0-12) that shows the audio spectrum in a realistic way (I think 0-20,000 hz)

I have already searched the internet for tutorials, but these have never seemed to work.  I believe I should be either using the fix_fft or arduioFFT library, but I don't know how.

Can someone please help me with this; any help is appreciated!   
I'm usually the one needing help!
:D

PieterP

What Arduino are you using?

Read up on the Fast Fourier Transform, Fast Hartley Transform and Constant-Q Transform. Constant-Q is better suited for audio, but probably harder to implement.

Pieter

circuitdh

I am using an Arduino Mega 2560, and I have ready a few articles on FFT and constant-Q, i'm just struggling on implementing it on the Arduino platform.  Also I don't need anything super-accurate, it just needs to be somewhat realistic. (When i play something low, the lower frequencies go up, etc)
I'm usually the one needing help!
:D

PieterP

Sampling, calculating and driving LEDs at 40kHz is probably going to be an issue. I would consider using a more powerful processor, or use something like an MSGEQ7.

Grumpy_Mike

Quote
(I think 0-20,000 hz)
Not very realistic. While there is some energy in music above 10KHz their is very little of it.

Here is what I did with an MSEQ7
https://vimeo.com/167914646

circuitdh


Not very realistic. While there is some energy in music above 10KHz their is very little of it.

Here is what I did with an MSEQ7
https://vimeo.com/167914646
Im fine with using less than 20000 hz, it just needs to cover the full spectrum of most songs.  Also I can't use the MSGEQ7, as it only works with 7 frequencies, i need 16 (without making 1 for left and 1 for right audio like you did.)
Sampling, calculating and driving LEDs at 40kHz is probably going to be an issue. I would consider using a more powerful processor, or use something like an MSGEQ7.
What other type of processor should I use (I can't use the MSGEQ7) As said earlier, I can easily program the lighting, I just need a fast processor to do the sampling. Is there another processor that would work in this situation, or could I use 2, one for the sampling and 1 to drive the leds.

I'm usually the one needing help!
:D

Grumpy_Mike

#6
Jan 27, 2018, 11:30 pm Last Edit: Jan 27, 2018, 11:31 pm by Grumpy_Mike
Quote
Is there another processor that would work in this situation,
Teensy 3.6 or Arduino Zero

Quote
i need 16
No you want 16.

PieterP

Or you could keep it analog, building 16 analog band-pass filters, peak detectors and a multiplexer. That's how the MSGEQ7 does it. It requires a lot of soldering, but it could be easier than understanding everything involved in digital signal processing.

If you really want 16 bands, you could use 2 MSGEQ7's, one for each channel, and interpolate between the two lowest bands, for example.

What is your background in DSP, mathematics or electrical engineering?

Grumpy_Mike

Quote
you could use 2 MSGEQ7's, one for each channel, and interpolate between the two lowest bands, for example
What you could do is to use 2 MSGEQ7s and adjust the clock frequency of one so that it sits between the channels of the other. You can do this because they are switched capacitor filters so they are tuneable.

circuitdh

#9
Jan 28, 2018, 12:43 am Last Edit: Jan 28, 2018, 12:51 am by circuitdh
My background is in electrical engineering

Well, I don't ahve to have exactly 16 bands.  I have made 16 led panels, so I could use +/- a couple, but taking it down to 7 like the  MSGEQ7 is way to low.

I am fine with using 2 MSGEQ7's, for a total of 14 light bands, but I'm not sure how to adjust the clock frequency of one. There is a clock oscillator pin, but I'm not sure what frequencies to oscillate it at.
I'm usually the one needing help!
:D

Grumpy_Mike

Quote
There is a clock oscillator pin, but I'm not sure what frequencies to oscillate it at.
It tells you in the data sheet. It is only an RC oscillator so you just put a pot in series with a smaller resistor. So I think it is a 220K resistor so use a a 210K resistor and a 20K pot to get a bit of adjustment. Then you can tune it by "eye" or by putting in a fixed frequency and tuning for maximum or use an oscilloscope.

circuitdh

Ok, thanks for the info, i'll do that.  Now I'll just wait a month for the parts to come from eBay and I will post an update on how it when here. Thanks again!
I'm usually the one needing help!
:D

Grumpy_Mike

Just as an aside did you see what I did with that circuit later:- https://vimeo.com/184643867

circuitdh

I'm usually the one needing help!
:D

Go Up