Home Forums Sparkfun MP3 Shield Library Support Forum Reading Sound Volumes

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1803
    Anonymous
    Inactive

    I am trying to read the volume of the sound so that I can have an LED change in color and intensity with direct proportionality to the volume of the file being played from the speakers. So far, the sound working (thanks to Bill and Michael), and I soldered a wire into the right channel pin on the Mp3 Player Shield and I have it connected to Analog Pin 0. In the program I am trying to read the analog values and print them to the serial monitor, however, I keep getting a read from 200-300 and it doesn’t matter whether I unplug the wire from the analog pin or not so I am not sure why it isn’t reading the data. Any suggestions?
    Thanks

    #1804
    Bill
    Member

    You can make sure the analog pin is working by connecting it to GND or 5V and then you should see the values change. Just unplugging the wire shouldn’t always make the values change.

    Now ready the ‘volume’ of the output sound is a different story. Remember sound is sine wave signal. Reading it with an analog pin is going to produce different results depending when the sample was taken during the sine waveform. In order to do what you want, you should take several dozen samples and pick the biggest one to represent the amplitude of the sound at that time.

    #1810
    Anonymous
    Inactive

    Yeah, the analog pin is working after all, it just isn’t nearly as responsive to the music as I expected it to be. Basically, I am trying to sync an LED with the song being played. But it seems like the values are almost random. I even tried a trance song that begins just with a driving bass kick at quarter notes (you know, that typical….bump…bump…bump…bump) and yet the values are not what I had expected nor are they easy to work with. I tried mapping out a range of values to sort of “zoom in” and get a greater range and that made it a little bit better but still…

    How would I sync up the song with the LED?

    #1811
    Bill
    Member

    What you are asking is much, much more complicated then you think. Sound from music is made of of tons of frequencies. Just sampling the audio output will give you ‘random’ results because you have no idea where on the waveform the sample is getting taken.

     

    I suggesting googling for what you are trying to do. Here’s a link I found quickly of someone trying to do something like you:¬†http://arduino.cc/forum/index.php/topic,11829.0.html

    #1812
    Anonymous
    Inactive

    Yeah, I understand what you’re saying. I’m not looking to have an LED equalizer or anything. I just want the amplitude of the waveform to correspond to the brightness of the LED. I don’t need one specific for bass, one for treble, etc. Just the overall volume of the song, the amplitude of the audio waveform signal to fade the LED with varying intensity. I tried mapping it like I said, but even without the audio input to one of the analog pins, just the pin by itself when I read the values, they have electrical noise associated with them. If there was a way to mute the noise, I believe the resulting voltages on the pin would be only from the audio signal. Is there a way to do this?

    #1813
    Bill
    Member

    Take a look at this code:

     

    http://lowvoltage.wordpress.com/2011/05/15/min-max-sketch/

     

    It’s what you have to do in order to try and get an over all amplitude. just sampling a few times isn’t enough.

    #1818

    The cumulative patch .053 provide a VU meter feature. I have just added some functions to access it along with an Example command “V”. In the current pre-release version on my github

    VU Meter
    SCI_STATUS bit 9 enables VU meter, which calculates the peak sample value from both
    channels and returns the values in 3 dB resolution through SCI_AICTRL3. The high 8
    bits represent the left channel, the low 8 bits the right channel.
    Values from 0 to 31 are valid for both channels.
    The VU meter takes about 0.2MHz of processing power with 48 kHz samplerate.
    Received command: 4
    Playing: …
    Enter 1-9,s,d,+,-,i,>,<,p,R,t,m,M,g,h,O,o,D,S,V :
    Received command: V
    VU meter = 1
    Hit Any key to stop.
    VU: L = 1 / R = 1 dB
    VU: L = 1 / R = 1 dB
    VU: L = 13 / R = 13 dB
    VU: L = 11 / R = 14 dB
    VU: L = 16 / R = 19 dB
    VU: L = 15 / R = 18 dB
    VU: L = 19 / R = 21 dB
    VU: L = 20 / R = 21 dB
    VU: L = 19 / R = 23 dB
    VU: L = 22 / R = 19 dB
    VU meter = 0
    Enter 1-9,s,d,+,-,i,>,<,p,R,t,m,M,g,h,O,o,D,S,V :
    Noting the Sensitivity is only 3dB and time averaged. It is not great at detecting peaks. I also see that it is measuring from before the output amplifier stage. So changing the volume does not affect it. You can see this while doing the SineWav Test at different Volumes.

    Aside from this there is a Spectrum Analyzer plugin that can report bands.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.