Pages: [1] 2   Go Down
Author Topic: MP3 decoding code, NOT realtime  (Read 1403 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone have code for decoding MP3 files into PCM? I don't need to have the conversion go on in realtime as the audio is playing, just something that can read an MP3 (in small chunks of course)into memory from an SD card and convert it to PCM so that I could store it in another file for later playback. If not, can someone direct me to an article about decoding huffman code? (which is what most of the MP3 is made up of as far as I can tell)
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maybe libmad could be your starting point, i've seen it being used on a mbed, so it's not impossible to use

http://mbed.org/users/Gruenfrosch/code/madplayer/summary
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lots of sources at http://www.mp3-tech.org/programmer/decoding.html
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the responses! It's certainly going to take a while to combine and port all this code to an xmega but I'm sure the results will be worth it.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but I'm sure the results will be worth it.
Are you sure? I would have thought you would be better off doing this on your PC there are lots of applications that will do this. Why does it have to be on an arduino?
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why does it have to be on an arduino?
It's for a handheld device (think iPod touch) that I'm working on. All of the data for this device (images, songs, text files, etc.) will be stored on an SD card. Every time I want to listen to a song, I'll decode it, play it, and then erase the decoded version. If all my songs were stored as wav files then I wouldn't be able to store nearly as many.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not just use a shield/chip that can decode mp3s directly?
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted to keep costs down and board layout simple. Seeing as it doesn't have to be realtime, software seemed like a fine solution
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you planning to output audio?
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How are you planning to output audio?
http://www.analog.com/static/imported-files/data_sheets/AD5663.pdf
I have another topic in the audio section talking about it, as I'm not sure which SPI mode to use to talk to it.
Logged

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

This document says 12344 bytes for MP3 decoder. http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATA_BRIEF/DM00024441.pdf
Looks like memory size is the main problem.
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 593
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted to keep costs down and board layout simple. Seeing as it doesn't have to be realtime, software seemed like a fine solution

How are you planning to output audio?
http://www.analog.com/static/imported-files/data_sheets/AD5663.pdf
I have another topic in the audio section talking about it, as I'm not sure which SPI mode to use to talk to it.

You know, the MP3 decoder chips output audio directly, so you don't need the AD5663 anymore. The board layout is still very simple.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 637
Posts: 34602
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Every time I want to listen to a song, I'll decode it, play it, and then erase the decoded version.
So you want to listen to a 3 minute track. You select it and hit play. Then there is a 10 minute delay before any sound is produced. Is this a system you want to use? Remember you said it did not have to be real time so you do know it will take longer than the playing time of the track to decode. 
Logged

Offline Offline
Full Member
***
Karma: 5
Posts: 207
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Magician So I'll read a smaller chunk. If I remember, one "page" of mp3 data is about 1K. Even if it's bigger, I still have 15K of RAM to spare.

@frank26080115 A separate DAC gives me the ability to create and send waveforms directly from the MCU as well. If I decide to implement something like a low frequency arb. wave generator then it will be easier to send the data directly to the DAC rather than packing it up into a format that the decoder will understand just for it to be decoded again.

@Grumpy_Mike It's certainly not the best solution to the problem, but for this low cost, low speed application I'm not going to complain. Worst comes to worst, I'll use a bigger SD card with wav files and try to make a fat32 compatible library.
Logged

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

So it is not arduino, than what is xmega?
Logged

Pages: [1] 2   Go Up
Jump to: