(08-05-2022, 03:09 AM)Spriggsy Wrote: This appears to be quite the conundrum. However, there is a definite way to do background music in a loop that can be killed whenever you want. You'd need to either open up a WAV file and then just allow it to continue playing using SNDLOOP until a certain key is pressed OR you can do something using the PlaySound function from Win32. You'd still need to use a WAV file OR learn how to make the WAVE resource in memory and pass it to the function. The function can run asynchronously and then you can kill the sound whenever you want.
I've never messed with the SOUND function before but maybe you should look into SNDOPENRAW, SNDRAW, and SNDCLOSE instead since you are working with frequencies and such. Those would allow you to kill the sound whenever without having to do some hacky thing with the C backend, Win32, threading, or premade WAV files.
For now I'm going to just record it as a digital audio file and use playsound.
I saw an example of SNDRAW but had questions, got busy, etc. Need to finally absorb the WAV file specification.
That said, why have a SOUND command if you can't stop it? I hope they add "support for SOUND(0,0) to stop sounds from playing" onto the backlog.
UPDATE: Here's a thought... The SOUND command is easy. That is in the spirit of BASIC. So why not create a function that emulates the SOUND command using SNDRAW etc.? Then we can support SOUND(0,0) ourselves, within that function! You could even extend it with all sorts of commands / functions that do things like change the waveform, set the volume and panning, etc.
Are you comfortable enough with SNDRAW to create a PLAYSOUND procedure?