views:

1364

answers:

5

Hi all,

This question has been in my mind for a few years and I never actually found the answer for this.

What I would like to do is extract the actual waveform/PCM of an MP3 file, so that I can play it using the soundcard (of course).

Ideally I would be experimenting some DSP effects.

My first step was to look into LAME, but I didn't find anything relevant about MP3 decoding in a program or stuff like that.

So I'm asking where I could find something like this.

What language should I use? I was thinking C, but maybe there are programming languages out there that would do the job more efficiently.

Thanks!

Guillaume.

+1  A: 

libmpg123 should do the trick.

Matt J
+1  A: 

I have been using the Windows Media SDK, not for this purpose, but I am pretty sure there are hooks let that let you intercept the audio stream, or convert MP4 to uncompressed WAV. I used C++.

cdonner
+1  A: 

Lots:

http://www.mp3-tech.org/programmer/decoding.html

Pick your poison...

Also, LAME does decode MP3s (check out --decode option), so you might find something interesting in that source.

Adam Davis
+1  A: 

It really depends what platform you are programming on and what you want to do with the code. If you are on Windows you should look at the windows media format sdk or DirectShow. They should both have the ability to decode mp3 files into the raw waveform. On the Mac, I would expect Quicktime to have this same ability. Others have already suggested source for Linux/open source code.

Steve Rowe
+2  A: 

The question boils down to: what are you trying to accomplish?

From the description of your question of decoding an MP3 and playing it on the sound card makes it sounds as if you are trying to make a media player.

However, if your intent is to play around with DSP effects, then it sounds like the question is more about processing the sound rather than decoding MP3s. if that's the case, probably looking into writing plug-ins for existing media players (such as Windows Media Player and Winamp) would be easiest path to what you're trying to accomplish.

Frankly, learning to write your own decoder from scratch is not just a programming problem but a mathematical one, so using existing libraries are the way to go. Talking to the operating system or libraries like DirectSound to output audio seems like unnecessary work if anything. I feel that working on plug-ins for existing players would be the way to go, unless your goal is to make your own media player.

If what you really want to accomplish is playing with audio data, then probably decoding an MP3 to uncompressed PCM using any MP3 decoder, then manipulating it in the language of your choice would accomplish your goal of dealing with effects with sound.

The language choice is going to depend on whether you are going to interact directly with MP3 decoding libraries, or whether you can just use raw audio input, which would allow you to use pretty much any language of your choice.

There was a similar question a while back, Getting started with programmatic audio, where I posted an answer on some basic ways to manipulate audio, such as amplification, changing playback speed, and doing some work with FFT.

coobird
You, sir, are awesome! I skimmed your answer and it looks amazing! I'm going to check it out tomorrow.Thanks!
Guillaume Gervais
Thank you, glad that I could help! :)
coobird