Thread: Playing sound files

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    1

    Question Playing sound files

    Hello,
    I've been taking C++ as a High School AP course, and currently we're writing our final program of the year. I've been wondering how to include sounds files (either as .wav or preferrably .mp3) into my program and play them. I use Metrowerk's CodeWarrior, which uses MS-DOS window for file execution. If you need more information about my compiler etc. let me know. I'd appreciate any help on this subject.

    Thanks,
    Brak

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    You must link your project to libwinmm.a

    In my compiler, you must add this directive to the compiler linker:

    -lwinmm

    This is good for .wav files, don't know about mp3...

    PlaySound("sound.wav", NULL, SND_ASYNC);

    ...works fine...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Playing MP3 files in C++
    By peyman_k in forum C++ Programming
    Replies: 6
    Last Post: 07-29-2008, 05:25 PM
  2. Playing a sound wave?
    By Blackroot in forum C++ Programming
    Replies: 1
    Last Post: 01-08-2006, 02:01 AM
  3. Playing sound without internal speaker in C
    By Rainy in forum C Programming
    Replies: 1
    Last Post: 03-30-2005, 11:24 AM
  4. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. Help me modify my Sound Server
    By zdude in forum C Programming
    Replies: 1
    Last Post: 05-14-2003, 05:15 PM