5

I have searched high and low, and cannot find any decent MP3 decoders =/

I need one that will compile under gcc/linux.

The closest thing i could find was libmad, which has no documentation at all, and the only example I could find was the one on their home page, which is really complicated.

Does anyone know where I can find one?

CuriousGeorge
  • 7,120
  • 6
  • 42
  • 74
  • Have you looked at lame? http://lame.sourceforge.net/ – Brian Kelly Jun 02 '11 at 03:11
  • yea...I was under the impression that it was only for encoding..I'll check again – CuriousGeorge Jun 02 '11 at 03:14
  • Looking at the command-line page: http://lame.cvs.sourceforge.net/viewvc/lame/lame/USAGE I can see at least a few options that look promising, such as `--decode` and `--mp3input`. That would hint that the underlying library has the ability to do what you need, I would imagine. Whether or not it has nice, well-encapsulated C++ functions for decoding mp3s is another story... – Brian Kelly Jun 02 '11 at 03:17
  • Note that if you add this to any of your projects and distribute them then you might run into patent trouble with Fraunhofer IIS and a few other companies who own rights to the MP3 technology. – Billy ONeal Jun 02 '11 at 03:17
  • @Brian: You should post that as an answer. – Billy ONeal Jun 02 '11 at 03:21

4 Answers4

4

Have you looked at Lame?

Looking at its command-line page, I can see at least a few options that look promising, such as --decode and --mp3input. That would hint that the underlying library has the ability to do what you need, I would imagine. Whether or not it has nice, well-encapsulated C++ functions for decoding mp3s is another story.

As correctly noted in the comments, you should carefully examine the licensing and patent agreements.

Brian Kelly
  • 19,067
  • 4
  • 53
  • 55
4

I have used MAD (MPEG Audio Decoder) in the past with great results, so I would not give up on it so quickly. MAD is specialy designed for good performance on CPUs without floating-point operations, which is desirable while developing applications for mobile devices for example.
I would like to recommend you to take a look on the source code of this project (GSPlayer). It is an audio player for Windows CE/Windows Mobile and it uses libmad. The code is fully functional, neat, and not too large, so it may help you to get an idea on how to use libmad on your own projects.

You may have to verify the license (GPL) for libmad though, since it may not suit your needs.

yms
  • 10,361
  • 3
  • 38
  • 68
  • 1
    He's already got license pain to deal with just by having the feature at all. Damn software patents. (And he also already referenced this in the question) – Billy ONeal Jun 02 '11 at 03:30
  • 2
    I finally got it to work...but it wasn't until I saw some FMOD example which made it super obvious that it is was the programmer's responsibility to provide their own read and write functions. In the other decoding example I was using for reference, the ogg vorbis lib was reading from the file and filling the buffer for itself =/ but I guess this kind of thing is done in favor of greater portability? which I definitely need for this. Thanks for the help :) – CuriousGeorge Jun 02 '11 at 17:16
  • excuse me, can I use MAD with Visual Studio 2019, if yes what do I have to do? can you link any sites that show/write in detail what I have to do? I have tried everything I have found online but I get errors. I use Windows 7 – platinoob_ Dec 28 '20 at 10:31
  • @platinoob_ using mad directly in Windows involves having knowledge of low-level Windows APIs. You will find the task very challenging if you need to learn such APIs now from scratch. – yms Dec 29 '20 at 16:41
  • @platinoob_ I suggest that you take a look to [libzplay](http://libzplay.sourceforge.net/) instead, it uses mad behind the scenes and it will be much easier for you to digest. You still need to know at least how to load dlls in Windows C++ application. To answer your question, I do not see why MAD library would not work under Windows 7 and VS2019, it's a regular Windows library with no particular prerequisites, but I have never tested it myself. – yms Dec 29 '20 at 16:42
  • @yms sorry to bother you again but I have one more question, from libmad.dsp I built a `.lib`(libmad.lib), is that enough to use mad in my programs? or somehow I need to build a `.dll` too? – platinoob_ Dec 30 '20 at 10:39
  • @platinoob_ That should be enough, see here: https://stackoverflow.com/questions/140061/when-to-use-dynamic-vs-static-libraries#:~:text=A%20static%20library%20must%20be%20linked%20into%20the,separate%20from%20the%20executable%20as%20a%20DLL%20file. – yms Dec 31 '20 at 12:36
2

ffmpeg should be able to handle MP3s without difficulty. How easy it is to actually access that functionality though, I cannot say.

Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
2

have a look at this application, very easy to use, programmed in C and works on windows/linux

http://sourceforge.net/projects/mp3decoder/