08-05-2022, 03:09 AM
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.
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.
Ask me about Windows API and maybe some Linux stuff