QB64-Phoenix-Edition / QB64pe

The QB64 Phoenix Edition Repository
https://qb64phoenix.com
Other
132 stars 26 forks source link

A way to stop and dispose all sounds played using _SNDPLAYCOPY #528

Open a740g opened 3 months ago

a740g commented 3 months ago

Is your feature request related to a problem? Please describe. There is no way to stop and dispose of sound copies until it finishes playing. For example, longer sound copies keep paying after a game level ends.

Describe the solution you'd like Something like _SNDSTOPCOPIES would allow stopping all sound copies in one go.

Describe alternatives you've considered This can be done on the BASIC side using arrays, _SNDOPEN, _SNDCOPY, _SNDPLAY & _SNDCLOSE. However, a fair amount of complexity is involved.

Additional context Stopping _SNDPLAYCOPY? Possible?

SteveMcNeill commented 3 months ago

Instead of a new command, might I suggest a tweaking of the existing commands?

_SNDSTOP handle, (flags$)

Where the optional flag$ would be "ONLY" <-- this only stops the original "COPIES" <--- this would stop the original and any _SNDPLAYCOPY "ALL" <-- this would stop the original and and copies.

Would save creating another sound related keyword for folks to have to chug through and remember, when there's already a boatload of them out there. Usage would be similar to:

h = _SNDOPEN("explosion.wav")
_SNDPLAY h
_SNDPLAYCOPY h
_SNDPLAYCOPY h
_SNDPLAYCOPY h

_SNDSTOP h, "ONLY"   <-- to stop the _SNDPLAY with the original
_SNDSTOP h, "COPIES" <-- to stop all copies using that original handle
_SNDSTOP h, "BOTH"  <--- to stop both at once
a740g commented 3 months ago

That would make the implementation a bit complex. However, it's a solid idea. Thanks @SteveMcNeill.

SteveMcNeill commented 3 months ago

Might also want to keep in mind the other sound commands. I'm not too certain how they all tie together, but it might not be too large a pain to add the same functionality to some of the other commands like the ones for pusing/resuming/volume control and such.