get peak values of amplitude of a song from MP3 player

Hello I would like to know if it's possible to write in the serial monitor the peak values of amplitude of a song from a MP3 player.

I would like to make something like this and also get the peak values: Arduino simple audio spectrum analyzer on OLED SSD1306 display - YouTube

I've seen others videos, but it is very nice because he doesn't use any IC, just Arduino.

I can't watch the video 'cause I'm at work...

The Arduino has an analog to digital converter, but it cannot directly accept the negative half of the audio waveform.*

The simplest solution is to use a biasing circuit [u]like this[/u]. The two equal value resistors bias the Arduino's analog input at 2.5V, and the 10uF capacitor blocks the DC from your audio circuit while allowing the signal through.

With the DC bias in place silence will read ~512. Audio signals will give readings above and below that level. If you want to remove that bias from your digital result, you can simply subtract 512 from your reading. You can either ignore the negative half of the cycle, or take the absolute value.

Since the audio goes through a cycle thousands of times per second (positive peak, through zero, negative peak, and back through zero again) you are going to get lots of random-looking readings. You'll need to take readings for 1 second or so and keep track of the peak, then start-over looking for a peak again.

With a line-level audio signal or a loud headphone output, you should be getting voltages peaks the ballpark of 1 Volt. That's about 200 on the ADC, so with the ~512 bias your readings should bounce around between ~300 & ~700. (That's just a ballpark estimate... It depends on your MP3 player, the loudness of the song, and the volume control setting.)

For my VU meter effect (and my other sound-activated lighting effects) I use a [u]Peak Detector Circuit[/u] which converts the AC waveform to a more slowly changing DC value that follows the peaks. Then, I only need to read it about 10 times per second and I don't need to bias the Arduino's input.

  • Negative voltages can damage the Arduino and/or the Arduino can "damage" (distort) the audio signal.