playing sounds in a DOS program

This is a discussion on playing sounds in a DOS program within the C++ Programming forums, part of the General Programming Boards category; how do i play sounds, such as a background song, in consul applications? also, is there a way i can ...

  1. #1
    Geo Geo Geo-Fry
    Join Date
    Feb 2003
    Posts
    116

    playing sounds in a DOS program

    how do i play sounds, such as a background song, in consul applications? also, is there a way i can have the song/sound/whatever "in" the program, so that the user doesnt have to have it saved on their computer? thanks

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    For a windows console application, you have to include windows.h. Then you can use PlaySound() to play a wave file from the disk, or the various MIDI functions. None of this is ANSI standard C++ stuff... Any graphics or sound requires non ANSI libraries.

    The problem with PlaySound is that it has to read from the disk "continuously" and it needs lots of CPU-bus time. so it's not usually a good idea to play wave sounds in the background. MIDI is easier on the processing load, because you're essentially just sending the set-up and the notes to the sound card. With wave files, you're sending 44K samples per second (per channel) for CD quality sound.

    I don't have any MIDI examples, but you should find lots of info in your compiler documentation/help.

    True DOS is another story. You'd need the old DOS sound card drivers which may not be available for your sound card.

    (Using the little internal PC speaker is another story too.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 08:48 AM
  2. Replies: 3
    Last Post: 12-03-2003, 09:15 AM
  3. DOS program path
    By CodeMonkey in forum C++ Programming
    Replies: 5
    Last Post: 10-02-2002, 07:56 PM
  4. DOS Program
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 02-12-2002, 07:55 PM
  5. Program to run in Dos only
    By ihsir in forum C++ Programming
    Replies: 2
    Last Post: 01-19-2002, 05:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21