0
\$\begingroup\$

For Arduino there are VS1053b-based MP3 shields and I do not understand some points. I asked for MP3 format but it can be generalised for other formats as well.

When a sound is recorded and encoded as MP3 and saved in SD card, why do we need a VS1053b encoder-decoder chip? Can't we just use a D/A converter to play it?

It seems to me we are just sending the sound file from the SD card to VS1053b chip over SPI and that chip is feeding that data to its own D/A converter.

So:

  1. What is the purpose of this VS1053b chip if we are just playing a file from an SD card?

  2. When we send hex values (samples of an MP3 file) from the SD card to VS1053b over SPI, is it processing those samples to recover the unencoded data (basically decoding)? If so, is this for better quality since we get rid of some data from file during MP3 encoding?

  3. Are these chips more meaningful if we, for example, record our voice with a microphone and let VS1053b encode that recording so we can take data over SPI and save it as an MP3 file?

Any help is appreciated.

\$\endgroup\$
  • \$\begingroup\$ MP3 recorders cost much more with an embedded license fee. So the shields do not support it. But decoders are inexpensive.Since they use code dictionaries during compression, it is not a linear DAC function. \$\endgroup\$ – Sunnyskyguy EE75 May 25 '17 at 1:39
1
\$\begingroup\$

What is the purpose of this VS1053b chip if we are just playing a file from an SD card?

MP3 is a compressed audio format. The file stored does not contain "raw" audio data (which would typically be some for of pulse-code modulation (PCM), but rather it contains a stream of data that must be decoded to obtain the actual audio data.

Hence, you need a decoder chip, because an Arduino (presumably, I'm not actually sure) does not have enough horsepower to do the decoding by itself. The decoding process involves many inverse frequency transforms and must happen in realtime; an MP3 stream contains blocks of frequency/amplitude information, and this must be converted back to the discrete time domain. If you had uncompressed audio data in a friendly format (WAV, for example, which stores LPCM-encoded audio and is trivial to decode), you would not need a complex decoder (but then the file would be much larger).

When we send hex values (samples of an MP3 file) from the SD card to VS1053b over SPI, is it processing those samples to recover the unencoded data (basically decoding)? If so, is this for better quality since we get rid of some data from file during MP3 encoding?

I highly suggest reading at least the beginning of the VS1053b datasheet, as well as the above link to MP3.

The MP3 file does not have raw samples, but sort of yes to the first question: the data is read from the SD card in blocks and the VS1053b decodes the incoming stream (by doing a lot of math), recovers (mostly) the original audio data, then sends this to an internal DAC and produces an analog voltage. (Remember that MP3 is a lossy codec, and therefore the output data sent to the DAC does not exactly match the input data that was originally encoded).

Quality doesn't really come into the picture, it's not for "better quality" because you have to decode the data. You can't just pass the data from the SD card to a regular DAC, because that data doesn't represent audio data in a way that the DAC can understand.

Are these chips more meaningful if we, for example, record our voice with a microphone and let VS1053b encode that recording so we can take data over SPI and save it as an MP3 file?

Well, they're "meaningful" because you need them to decoded MP3 files with such a limited processor (ATmega328). The VS1053b is an encoder, but not an MP3 encoder: it can encode IMA ADPCM and Ogg Vorbis. So, no, it can't record audio to an MP3 file, but it can record audio to other formats.

Hope that helps. To better understand MP3 compression, you'll want some background in time-frequency analysis and frequency domain operations (and I'm not sure how much of a background you've got).

\$\endgroup\$
  • \$\begingroup\$ Thank you that was the answer that i was looking for. I was thinking that the mp3 encoder just removes some parts and we still have the data like raw format. \$\endgroup\$ – snrIcmn May 25 '17 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.