in reply to Re^2: win32 sound problem
in thread win32 sound problem

Did you try calling CloseDevice()?

Maybe it's a bug in Win32::Sound. Try looking at the module's source code to see why it seems to retain state from a previous call. If it is a bug, maybe you'll be able to submit a patch and report it on CPAN.

A Super Search finds a similar issue: Win32::Sound buffer problems

Replies are listed 'Best First'.
Re^4: win32 sound problem
by spencoid (Acolyte) on Feb 27, 2011 at 22:53 UTC
    i tried close() and every other function i could find and never could get it to work. it does seem like a bug in win32 sound. i looked at the source code but could not figure out where the problem is, if it is there. it would help if someone who understands windows better than i do could look at the source code and maybe identify the problem.

      spencold:

      Perhaps it's allocating a buffer internally, and not shrinking it when you load a new sound. Do you get the remains of the first track after the second track plays? (Might be easier to tell if you play a song and then load your track.) If that's the case, it might lead you to a bugfix. Or perhaps load an appropriately long empty file (i.e. silence) before loading your tracks to work around the problem

      Finally, the docs show a Play(from, to) method. You might just use that method to play only the track you just loaded/created. It also shows a Reset() method. Perhaps the pointer in the device isn't being reset, so it's loading data into the wrong part of the buffer?

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        i tried everything you suggested and nothing works except for the fakery you suggested of loading an appropriately long bunch of silence. i now have it close to working. it seems that i have to overwrite the buffer with silence as you suggested. now i just need to calculate the amount of silence needed instead of making it a huge amount. too bad that this work around is needed but i am so pleased that you got me looking in a direction i would never have thought of.so it looks like the soundcard buffer is not purged by reset or anything else and has to be completely overwritten with silence. if anyone is listening, i would still like to know how to fix the win32 sound module.