Pages: 1 [2]   Go Down
Author Topic: Driving LEDs with audio  (Read 3719 times)
0 Members and 1 Guest are viewing this topic.
Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using an FFT is not going to do what the OP asked for. Yes it will give you a nice display but it will not pick out a single note and allow you to light an LED. It will light LEDs according to the spectrum of the waveform. That is you will get a different display from the same note, depending on the not's harmonic content.
And this is perfectly fine.  As long as it's "close enough".  I do need to distinguish the differences between a lower and higher octave C being hit.  And I *think* I can get that on a regular spectrum as one will generate more bass than the other.  However, don't quote me on that, I don't have anything to test with right now.  But this is also why I'm asking questions here before I try to actually make something.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you look closely, you will find that most keyboard players have 10 fingers, typically 5 on each hand. If you don't allow for polyphony, then you are not making something that practical to use in the Real World.
However, on this particular instrument, the most notes that can be played at any given time would be 4 ... there's only so many mallets these kids know how to play with.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To Magician:

Ok, so if I read that right, you have pins 2-5, 6-9, and 10-13 assigned to red, green, and blue.  Those pins go to two darlingtons which then drive the LEDs.  Am I correct in assuming you're driving the Arduino with 12V then?  I see a mic plugged into analog 0 - I'm assuming that board the mic is on is an amp then?

Based on the above, you're using 12 pins, that's 12 channels.  Still (quite a bit) short of my goal of 67 frequency bands.  I must be missing something ... the Arduino, in this particular setup, won't have enough pins to drive all the frequencies.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's in description, just on right side of schematic:
12 V;
mic + IC NE5532;
only 3 "hardware" channels (RGB).  There are 64 define in software: #define FFT_SIZE  64.
For color-music project 64 more than enough, 31 in use only.

Your project will require more bins/channels/bands, to calculate exact value I need to know:
1). lowest and highest notes on keyboard;
2). what kind of arduino board are you gonna use;
If you didn't decide on type on board, go for "Arduino Mega 2560".
There is a chance, that with UNO would not be possible to cover all range of keyboard.

For output, as you notice, not enough pins, shift register IC would be necessary. But it last thing to
worry about. I'd suggest, debugging all software first with just a serial monitor.
Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, about 30 minutes after I posted my questions, I realized ... I don't need that many pins because I'll be driving an addressable strip, so 4 pins ought to be enough.  Or I can also drive a bunch of 5940NTs for individual LEDs, in which case 5 pins is enough.

As for the lowest and highest notes, I presume you want that in frequency?  That's not something I can provide because I don't have any way of measuring that.  I just had one of the kids e-mail me and say that they won't be using their largest one (5.5 octaves), but instead opted for the smaller ones of which they have several - that way it will all be the same (whatever that means.)  Anyway, the smaller ones are 4 octaves.  They have a xylophone and several vibes that are in the 3.5 range as well and if all goes as planned, they would want those wired up as well.  I'm going to work with one thing at a time here, starting with the largest one.  If it works out, then I'll figure out the rest.

Thanks for the help and guidance.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, you don't have to measure, ask google, ba***rd knows everything  smiley
Wikipedia is good too. This what I find on instrument:
http://en.wikipedia.org/wiki/Vibraphone#Range
So,  they say range F3 - F6.
Using next link gives a frequency:
http://en.wikipedia.org/wiki/Piano_key_frequencies
33   f   F3   174.614
69   f′′′   F6   1396.91

You don't expect me to write all project for you, do you?
I can only provide general guidance, and this is what I came across (google was helpfull):
1. Solder input mic amplifier, or get from sparkfun;
2. Rough estimation shows me that, it will works on UNO. I didn't count memory requirements for tlc5940 or other IC would be in use for output. To play safe and have a slack, Mega 2560 preferable.
Things to read, and absolutely understanding theory behind it, things to modify in software:

1. (FFT) Resolution required for F3 note is 5 Hz. In color-music this value 70 Hz. To make it x16 times   better, steps to be taken:
 #define FFT_SIZE      512
 #define log2FFT       9

2. (Nyquist theorem) Decrease sampling frequency by factor 2, bring it down from 8.8 to 4.4 kHz.
    Read two sample, calculate average, store in input array.
    It additionally will improve SNR on 3 dB.

3. (Zero padding). Straight forward approach would increase latency in system, approximately
    8 times, up to 28 ms x 8 = 224 ms.  To keep it below 100 ms, I'd suggest get better resolution by     zero padding, not only extending input data array. 

But make you research, there a lot of publication "musical note recognition" or similar.


Logged

Colorado
Offline Offline
Edison Member
*
Karma: 47
Posts: 1562
Reviving dead brain cells with Arduinos.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nope, no need to write anything ... you already did.  I just need to figure it out now.  And the standard marimba range they have is 4.3 octaves, or A2 to C7 ... had to dig that up myself earlier today when one of the kids finally woke up (it is summer vacation after all.)  They have at least one that's E2 to C7 but as I said before, I don't know what they'll be using.  The standards for sure, the rest is a toss up.

So my task right now is to first get a setup to start testing which involves needing to either build a small amp, or just buy the thing from SFE ... might just do that.  Then make a small test rig and start tweaking the code ...  You've given me several pointers already, both on your site as well as on here so I think for now I just need to go do my homework and burn a few fingers.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check it out:
http://musicalnoterecognition.blogspot.com/
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very cool video!
KE7GKP is such a Downer...  He's gone now.
"Your expectations are unrealistic" over and over in each thread in the Forum.
Maybe he failed with his Arduino project?  It happens we all do sometimes.
I'd like to point out, unless it's a lie, the video proves he was wrong!

I'm doing this too, as a learning exercise writing my own code.  
I'll check out yours when I'm finished!
I've done it before on a PC.
Free samples, Mic preamp:
http://www.datasheetcatalog.org/datasheet/analogdevices/SSM2166S.pdf
Has many advanced features...
« Last Edit: September 26, 2011, 07:52:25 am by sbright33 » Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the link, I'll look into it.   There is one more similar project:
http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2011/sap76_rns49/index.html

Students missed out very important part - rounding error (I was trying to explain it in my blog recently, probably not very well, and anyway too late for them  smiley-sad )

So their design only able recognize 1 note at a time (monophonic), 4 times longer notes (1/4 instead of 1/16) using better Atmel chip.

Some idea explain well, hope you will find it useful to read
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great website!  Very edumacational.  My hardware is MUCH simpler.  The low pass Nyquist filter is done in software with only a few lines of code.  It's really just oversampling.  For a Mic preamp I used the chip I mentioned above with a few external parts.  It has many advanced features.  Alternatively I interfaced to a PC, iPod, or stereo using a variable resistor only.  That is how you adjust the DC offset.  You can adjust the gain for testing using the volume control.  You can sample at 32khz if you want, but in your case obviously it is not needed.  Keep up the good work!
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Pages: 1 [2]   Go Up
Jump to: