Thread: PlaySound repetitive playback

  1. #1
    Registered User
    Join Date
    Jun 2006

    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
    Farncombe, Surrey, England
    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".

    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
    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
    near a computer
    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, 07:10 AM
  3. PlaySound function & Console App
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 06-26-2002, 12:25 PM
  4. about playsound()
    By Sekti in forum C++ Programming
    Replies: 0
    Last Post: 04-08-2002, 05:29 PM
  5. PlaySound();
    By tHaPuTeR in forum Windows Programming
    Replies: 2
    Last Post: 03-11-2002, 07:30 AM