Thread: Playing MP3 files in C++

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    7

    Playing MP3 files in C++

    Hi all,

    How can I play MP3 files in C++? Is there any library that I can use?

    Thanks,
    Peyman

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    In the C++ standard library, no. SDL, however, might support such a thing.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Google for "MP3 files in C++".

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    I found libmpg123 to be a good library.

    Also, be aware of the legal implications - MP3 is patented. Depending on what you're doing, other formats may suit you better. (In the local gamedev club, the last project I worked with used .ogg files. Supported by SDL, excellent quality, and free.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    7
    Quote Originally Posted by Cactus_Hugger View Post
    I found libmpg123 to be a good library.

    Also, be aware of the legal implications - MP3 is patented. Depending on what you're doing, other formats may suit you better. (In the local gamedev club, the last project I worked with used .ogg files. Supported by SDL, excellent quality, and free.)
    Hi,

    That is for Linux, is there any version for windows also?

    Thanks,
    Peyman

  6. #6

    Join Date
    May 2005
    Posts
    1,042
    FMOD, DirectSound, OpenAL. I use FMOD.
    I'm not immature, I'm refined in the opposite direction.

  7. #7
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Quote Originally Posted by peyman_k View Post
    Hi,

    That is for Linux, is there any version for windows also?

    Thanks,
    Peyman
    Yes, libmpg123 works with Windows. They seem to have a developer zip file on the website's download page, but IIRC, I just compiled from source.
    I forgot to note that libmpg123 provides only decoding support, IIRC. I don't think they have any code for playing sound. (You've got two tasks here: decoding the mp3 and playing the resulting waveform.) Some of the libraries mentioned above can help with that. (Some might be able to do both decoding/playing in one or two steps - for me, this was not needed.)
    Last edited by Cactus_Hugger; 07-29-2008 at 05:29 PM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 10:56 AM
  3. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  4. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  5. playing .mmf files
    By Ruski in forum Windows Programming
    Replies: 2
    Last Post: 06-17-2005, 09:49 PM