PlaySound repetitive playback

This is a discussion on PlaySound repetitive playback within the Windows Programming forums, part of the Platform Specific Boards category; I have a program which plays a sound depending on input from the user. The source file is a single ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    36

    PlaySound repetitive playback

    I have a program which plays a sound depending on input from the user. The source file is a single file that is overwritten when the user makes a new choice. The problem is, it plays the sound so that it 'lags' with the input. Say, I can play sound A, switch to sound B, play it and it will play sound A (?), after playing again, it will THEN play sound B. Any ideas?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What mechanism are you using for "playing a sound"? What OS is it?

    If you are using Windows PlaySound, it's got a parameter to say "if you ask for another sound to be played, abort current playing".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    36
    I made an error. It is not fault of playsound, but because ShellExecute returns before the program it calls is done processing, causing the immediately following PlaySound to play and old .wav. I looked in system() and spawn() series but they popup a console window, while they do wait until processing of the called application is done. I looked into CreateProcess but I'm confused on how you would make it wait until it is done with the called program.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Look at 'Wave form Audio' [Winmm.lib] if you want better control over how the sounds are played.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PlaySound doesn't play when called!
    By Queatrix in forum Windows Programming
    Replies: 7
    Last Post: 03-03-2006, 08:02 PM
  2. PlaySound error
    By Shadow12345 in forum Windows Programming
    Replies: 5
    Last Post: 10-02-2002, 08:10 AM
  3. PlaySound function & Console App
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 06-26-2002, 01:25 PM
  4. about playsound()
    By Sekti in forum C++ Programming
    Replies: 0
    Last Post: 04-08-2002, 06:29 PM
  5. PlaySound();
    By tHaPuTeR in forum Windows Programming
    Replies: 2
    Last Post: 03-11-2002, 07:30 AM

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