Pages: [1] 2   Go Down
Author Topic: Spectrum analyzer - collect audio signal without interfering with output line  (Read 3008 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Montreal
Online Online
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 505
Posts: 31337
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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

Quote
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.
Logged

Montreal
Online Online
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
ground to ground that would be the ground of LM4863 (pin2,7 and 15) to Arduino's ground, right?
Right.
Quote
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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-cool

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
Logged

Montreal
Online Online
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...)
Logged

Montreal
Online Online
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What kind of arduino board?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 505
Posts: 31337
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-lol. 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).

Logged

Montreal
Online Online
Edison Member
*
Karma: 23
Posts: 2483
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Useful FFT (/ FHT) library - http://wiki.openmusiclabs.com/wiki/ArduinoFHT  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!)



Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: