Results 1 to 4 of 4

Thread: PlaySound API doesn't play to completion.

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    PlaySound API doesn't play to completion.

    I'm using the PlaySound API call in VB6. My OS is Windows 7 Home Premium x64.

    When I generate a wave form that has lets say a 1000Hz sine wave, that plays for exactly 10000 complete cycles of this waveform, and then send it (along with the correct WAV header) to the PlaySound API call, with it set to play in memory (so that it loads my waveform and wav header from the byte Array I'm sending it), I find it truncates the output audio. I can tell because if I use a loopback, and then have another known working audio program like GoldWave recording the audio, I find that audio output from my program is truncated (the waveform in the last cycle is chopped off prior to completion by my sound generating program, or more specifically by the PlaySound API it depends on to output the audio). And I've checked the WAV header multiple times in my program, and it is correct (proper blockallign, bit-depth, etc). And when I save my WAV header and byte array of the waveform to a .wav file, and load that into GoldWave audio software, I find that my complete waveform data is present (the last sine wave cycle is not truncated). So it appears that my PlaySound API isn't reading/playing all the data in the byte array.

    Is this a known problem? And is there a known fix for it?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: PlaySound API doesn't play to completion.

    Have you checked if the same issue happens in other OSs? How are you calling the PlaySound API?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: PlaySound API doesn't play to completion.

    Quote Originally Posted by Bonnie West View Post
    Have you checked if the same issue happens in other OSs? How are you calling the PlaySound API?
    I don't think anything is wrong with my code. I've double, triple, and quadruple checked my code and nothing looks wrong. I've decided instead to use DirectSound from DirectX8 instead, as I have found it has less buggyness (even though it is more of a hassle to set up).

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: PlaySound API doesn't play to completion.

    Quote Originally Posted by Ben321 View Post
    I don't think anything is wrong with my code. I've double, triple, and quadruple checked my code and nothing looks wrong. I've decided instead to use DirectSound from DirectX8 instead, as I have found it has less buggyness (even though it is more of a hassle to set up).
    What code are you using? Also, if this thread is finished with please mark it "Resolved".
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

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



Click Here to Expand Forum to Full Width