Thread: Music in C++ and external files

  1. #1
    Registered User
    Join Date
    May 2005

    Music in C++ and external files

    I have two questions:
    1. I wanted to know if its possible to include music (like mp3, wav...) inside the code. if not which would be the most similar way to do it?
    2. Is there a way to run external .exe files inside the codification?


  2. #2
    Hardware Engineer
    Join Date
    Sep 2001

    PlaySound() & system()

    There is no sound in ANSI/ISO standard C++. Assuming that you are running Windows, PlaySound() is probably the easiest way to play a wave file. I'm pretty sure the Windows API does not include an MP3 decoder. I assume you can find a 3rd party library what will play an MP3.

    You can run another program with system()
    system("C:\Program Files\SomeProgram.exe");

    The system() function is standard, but using it usually makes your program system-specific.... because the stuff inside the parenthesis is usually non-standard!

    There are also DirectX / DirectSound functions which better utilize your system resources when playing sounds. If you're making a CPU intensive game, you would probably want to mostly use MIDI sound, as it puts very little demand on your CPU & data bus.
    Last edited by DougDbug; 05-20-2005 at 11:19 AM.

Popular pages Recent additions subscribe to a feed