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

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.

Replies are listed 'Best First'.
Re^5: win32 sound problem
by roboticus (Chancellor) on Feb 28, 2011 at 01:01 UTC

    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.

        spencold:

        I'm glad that the workaround is taking care of you. I'm booked solid through this week, but if you remind me on Friday, I'll be happy to look at it over the weekend and see if I can find anything I can fix.

        ...roboticus

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

        if anyone is listening, i would still like to know how to fix the win32 sound module.
        I'll reiterate: you need to submit a bug report to have any chance of this being fixed. You can't assume the module author is listening here at PerlMonks.