+ Reply to Thread
Results 1 to 7 of 7

Thread: PlaySound() pauses game problem

  1. #1
    Senior Member
    Join Date
    Sep 2004
    Location
    Perth, Australia
    Posts
    179

    Default PlaySound() pauses game problem

    Hi all,

    I have written my first game using Win32 and C, the old fashioned way. I know, I must be a masochist. Anyway, I want to add a sound effect when a row is completed (can you guess the genre yet?!). So I use PlaySound() to load the .wav from my resources and play it asynchronously. This works, but the first time it is played there is a noticeable pause in the game as the sound is loaded. It pauses for about one second. After that I guess the sound is cached because it plays quickly. Anyway, how can I fix the pause when the sound is loaded? Is there a way to preload sounds at the beginning of the game, without actually playing them?

    If I must use DirectX, can I just use the audio part and nothing else?

    Thanks,
    20thCB

  2. #2
    Member
    Join Date
    Aug 2004
    Location
    Poland
    Posts
    66

    Default

    Don't know exaclty how playsound works, but rather avoid it.

    You can use only Dx part responsible for sound/music playback (if you do so, use as old version of dx as possible to avoid possible problems with "you need to install dx9 in order to run this game...")

    Another idea is to simply find a simple sound-playback source and use it. Loading Wav's and playing them is pretty straightforward

    Ok here's a tutorial with sample code for using both waveout method and dsound to play sound.

    http://www.gamedev.net/reference/art...rticle1348.asp

    Generally Waveout is better for you as you don't need dx for it, but for more advance functions (which you don't seem to need atm) you will want to consider dsound.
    Last edited by MirekCz; 09-23-2004 at 12:49 AM.

  3. #3
    Senior Member
    Join Date
    Jul 2004
    Location
    Durham, UK
    Posts
    4,873

    Default

    I'd seriously consider FMOD, BASS or OpenAL to do your sound for you. No headaches, it's all Good Stuff.

    Cas

  4. #4
    Senior Member
    Join Date
    Sep 2004
    Location
    Perth, Australia
    Posts
    179

    Default

    FMOD looks great. $2,000 per title?!
    Phew, there's a hobbyist licence

  5. #5
    Senior Member
    Join Date
    Jul 2004
    Location
    Durham, UK
    Posts
    4,873

    Default

    I believe there's a cheapass license for shareware devs at $100 isn't there...?

    Cas

  6. #6
    Senior Member
    Join Date
    Jul 2004
    Posts
    543

    Default

    Yes - down the page a bit.

  7. #7

    Default

    Quote Originally Posted by 20thCenturyBoy
    Hi all,

    I have written my first game using Win32 and C, the old fashioned way. I know, I must be a masochist. Anyway, I want to add a sound effect when a row is completed (can you guess the genre yet?!). So I use PlaySound() to load the .wav from my resources and play it asynchronously. This works, but the first time it is played there is a noticeable pause in the game as the sound is loaded. It pauses for about one second. After that I guess the sound is cached because it plays quickly. Anyway, how can I fix the pause when the sound is loaded? Is there a way to preload sounds at the beginning of the game, without actually playing them?

    If I must use DirectX, can I just use the audio part and nothing else?

    Thanks,
    20thCB
    LockResource on the sound will do it

    pat.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts