Arduino Forum

Using Arduino => Project Guidance => Topic started by: kakotes on Oct 21, 2011, 11:16 pm

Title: Music to vibration
Post by: kakotes on Oct 21, 2011, 11:16 pm
Hello,

I'm new to Arduino and I am currently trying to make a device that turns music from an mp3 player into vibrations (using small vibrating motors, about 5 of them, one for each frequency range), according to the different frequency ranges and their intensities (kinda like a spectrum analyzer, but with fewer frequency ranges). I've already connected an mp3 player to the arduino using the following circuit to get a ~2.5 V DC offset:
                        + 5V
                           |
                           <
                           > 10k
                           <
             220 uF     |
mp3-------) |---------------- Arduino A0
                           |
                           <
                           > 10k
                           <
                           |
                         Gnd

My questions are:
1. On the 0-1023 input range, the values go from around 490 to 530. Should I amplify the signal before feeding it to the arduino? If so, what circuit do you recommend?
2. How would I implement an FFT algorithm to get the intensity of each frequency range? I already tried elmchan's fft library but I can't get it to work.
3. I'm thinking about using PWM to control the vibration motors. Is this a good idea?

Thanks in advance!
Title: Re: Music to vibration
Post by: winner10920 on Oct 22, 2011, 06:54 am
If you are not against adding an ic, look into msgeq7
I haven't gotten to play with one, still shipping but it is basically a spectrum analyzer that outputs a multiplexed voltage for 7 channels of frequency
I think it would simplify your project to have an ic do all the hard work, you would just poll it for data and read that
like say use just 5  channels control 5 vibrator circuits directly, if pwm does work then map the analog 0/1023 to 0/255 for a simple solution
im planning on using it for a light orchestra sort of deal for a car, having leds go off in the sub for low frequencys, mid to mod range speaker and highs to my tweeter lights, I will probably map it to getbthe brightnesss according
here's the sparkfun page
http://www.sparkfun.com/products/10024
They have it retired but I bought 5 brand new for 8.99 off ebay including shipping
Title: Re: Music to vibration
Post by: kakotes on Oct 22, 2011, 12:52 pm
That's a great ideia, hadn't thought of that. Just one more question: if i plug the msgeq7 output to arduino analog input, what kind of values would i be getting on the arduino and how would i use them to get the different frequency ranges?

Thanks for the reply!
Title: Re: Music to vibration
Post by: kakotes on Oct 22, 2011, 01:03 pm
I've found a site that explains pretty much everything ^^
http://skoba.no-ip.org/msgeq7/index.html

Thanks a lot for your reply, winner10920, it really helped me! :)

Title: Re: Music to vibration
Post by: trigonometry on Jun 13, 2013, 04:42 pm
Hello!
I am working on a similar project. The link on the last reply is broken... does anyone have a cache or know of where that information can be found?
Thanks
Title: Re: Music to vibration
Post by: winner10920 on Jul 19, 2013, 03:24 am
if i helps here is some of my code from my projects, not commented perfectly but it should help you play around with it
Title: Re: Music to vibration
Post by: rickso234 on Jul 19, 2013, 06:24 am
That link didn't work, but this (may be the same page) appears to work...
http://nuewire.com/info-archive/msgeq7-by-j-skoba/ (http://nuewire.com/info-archive/msgeq7-by-j-skoba/)
Title: Re: Music to vibration
Post by: jroorda on Jul 20, 2013, 12:01 am
I suspect you may be going with the msgeq7, as it is a great fit for this application, but I hate to leave a good question unanswered. 

To get a good amount of resolution using the analog inputs on the Arduino you definitely want to amplify the signal. I did a project like this last year and I just used a fairly normal op amp.  I can look up the exact model if you want.  It was special in that it could run from one supply +5V instead  of +5 and -5V and drive close to either rail.  I think I amplified by about 10 to 20 times and I biased the center of the signal up to 2.5V.  If you don't do this you will get lots of distortion as half of the wave is below 0 on the ADC not to mention the op amp.

From there I would use the FHT library to do a 5 bin FFT and from there all you need to do is control the motors.