Spectrum analyzer - collect audio signal without interfering with output line

Hi guys,

I have an audio bluetooth demo board from Bolutek (see demo board below - BLK-MD-SPK-D_demo - http://www.bolutek.cn/Products_info.asp?TypeID=104&SubTypeID=104001&id=293) that works great to remotely play music via bluetooth directly to headphones or small 2w speakers.

I want to create a spectrum analyzer from the audio that comes out from this board using the FTT examples available in the arduino playground.
My problem is that I am a newbie in electronics and I am not sure how to collect the audio signal from this demo board to the arduino without interfering with the headphones/speakers output.

The demo board uses a LM4863S audio amplifier to deal with the audio signal from the bluetooth IC and output it to the headphones/speakers (audio comes out of speakers if no headphones are connected. If headphones are connected, the audio from speakers is cut-off and audio only comes out of headphones). There isn't much info available for this board (unless you can speak Chinese ;-))..but you can always understand the schematics of it in its datasheet http://wenku.baidu.com/view/0047cd17b7360b4c2e3f64bf.html - see page 8 (sorry for the link, couldn't download the pdf).

Could anyone suggest me how may I collect a suitable signal from this demo board (either collect it from bluetooth IC or from LM4863S circuit) to be analysed by an arduino nano using the FFT code and generate the audio frequency spectrum while still having the audio normally coming out of the speakers/headphones.
If you need any further details, please let me know.
Thank you in advance!
Pfrogs

Just connect ground to ground, and ether 5(Left channel) or 12(Right) pins of 4863 to arduino analog input (5V board arduino, with 3.3V use resistive divider 1:1.7)

Thank you Magician!
Just to make be sure, when you say connect ground to ground that would be the ground of LM4863 (pin2,7 and 15) to Arduino's ground, right?
My problem here is that arduino and the bluetooth module are currently feed from different power sources. The module actually has its own Lipo battery and charger incorporated in its circuitry, so I guess I will have to figure out how to feed it from the same power as the arduino for this to work out, right?

Additionally, I am just wondering why do you say to connect the arduino analog input to Lout- or Rout- of LM4863 and why not to Lout+ or Lout+ (maybe it can also be this way, but I am not sure... Is this to bypass the headphones function?).

Also, will connecting the analog input to the same pin that speakers connect not interfere with the sound volume/power of the speakers? I would imagine that it would lower the signal power and hence its volume...but then again I am a newbie and can't still quite understand the op-amp circuit of the LM4863.

Sorry to be asking so many things...just wanted to understand a bit more about how things work here.
Again, thanks alot for your attention!

so I guess I will have to figure out how to feed it from the same power as the arduino for this to work out, right?

No separate power supplies are fine just connect the grounds together, see:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

Also, will connecting the analog input to the same pin that speakers connect not interfere with the sound volume/power of the speakers?

No the arduino input is so high in impedance there will be no extra load.

ground to ground that would be the ground of LM4863 (pin2,7 and 15) to Arduino's ground, right?

Right.

I am just wondering why do you say to connect the arduino analog input to Lout- or Rout- of LM4863 and why not to Lout+ or Lout+

I was thinking distortion level 'd be less on those pins (5, 12), compare to 3, 14 where second inverting amplifier implemented. Shouldn't be much difference, 1% isn't an issue for your application?
If you want to play safe , put a resistor in series with arduino analog input, 5-10 kOHM, that 'd save arduino if you made mistake with polarity

Thank you Grumpy_Mike and Magician!
Always glad to learn more about this things. And yes, I think I can live well with 1% distortion level 8)

Not wanting to abuse much of your kindness, may I ask you a final question about this subject?

Is it possible to have both right and left channels mixed into the arduino analog input? I ask you this because I would want the spectrum analyzer to respond to both right and left channels.
Would that be correctly achieved by connecting both Lout- or Rout- to the arduino analog input using a 5-10 kohm resistor in series from each channel, and ground to ground?

Something like this...
10 kohm
Lout- -----^^^^-----
|
| ----arduino analog input
|
Rout- -----^^^^-----
10 kohm

LM4863 ground ---------------- arduino's ground

Looks o'k, simplest mixer. Have you defined sampling rate? There is no hardware filter, so you need to sample at least 40 kHz for audio

From what I've seen around, yes, I was aiming for 40KHz ..to cover the human hearing range of up to 20KHz (2x times this according to "Nyquist's Theorem").
What I am not sure is how high can I go in sample rating using FTT and the arduino, which at the same time will be controlling some i2c pwm drivers IC that I wanted to use to drive some RGB leds.
Any recommendations here?

Also, do you think that I should add a capacitor in series with the resistor to filter sound signal? (if this is actually works this way...)

What kind of arduino board?

From what I've seen around, yes, I was aiming for 40KHz

Unless you have a Due then forget it.

Forget it anyway, with only 10 or 12 bits it is not worth sampling so fast, the perceived differences are very small unless you are a hi-fi nut.

Magician: I was planing on using an Arduino Nano 3.0 (ATmega328) I have..but I can get a different one if it justifies.

Grumpy_Mike: I'm certainly not looking for HiFi here (will leave that for the experts XD. What rate would you recommend to get a fair graphical frequency spectrum divided in 12 or 16 channels (I haven't decided this part yet).

It was not clear what for you need a spectrum, visual led's display is the easiest application, where you don't need right sampling rate - anything above 10 kHz is o'k, no big issues with aliasing, as energy in normal musical content doesn't go up so far, and plus you don't care for real-time, interleaving sampling-processing is o'key. Check on a link in signature, may be that 'd answer all your questions.

Thanks Magician. Actually, I had already been sneaking around your link before. Nice work! :slight_smile:
Hope to get some free time soon to start messing around with my own spectrum analyzer.
Cheers!

Useful FFT (/ FHT) library - ArduinoFHT - Open Music Labs Wiki Does exactly what it says on the tin...!

Also has some useful extra extra fns for combing fft bins together, as how humans percieve audio isn't correlated to it's exact measurements. e.g. humans can theoretically hear up to 20khz, but most above 5khz can be discarded for visualising stuff (IMO anyway!)

Also very useful for drawing graphic output in realtime - http://accrochages.drone.ws/en/node/90 - to aid debugging.

I modified the processing code to draw the FFT bars in realtime as well as the raw audio input.

sorry final bit of spam from me...I found the code in this project very useful as well: Overview | Tiny Arduino Music Visualizer | Adafruit Learning System

It autoscales to the volume, and does some calculations to get an output that looks decent.

Hi markvr,

thank you for sharing your info...some of which I had already came across during my research :slight_smile:
I just started to play with the arduino and FFT and I am still trying to get it how it all works and how to set it up for my project..so every info will be welcome.

Btw, I have tried connecting things as stated before and it worked ok, but still had a lot of noise with this.
So I tried modifying this by adapting a circuit I've seen at Arduinoos' Didier blog http://www.arduinoos.com/wordpress/wp-content/uploads/MicroLS_05.jpg and it works like a charm..most of the noise disappeared (at least I no longer get a signal when no audio is coming out of the speakers).