Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do you stop a sequence of sounds created with the Sound command?
#7
(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? Big Grin
Reply


Messages In This Thread
RE: how do you stop a sequence of sounds created with the Sound command? - by madscijr - 08-05-2022, 03:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Command$(count%) - I can't get a value when using the optional argument "(count%)" Unatic 3 530 08-22-2025, 11:58 AM
Last Post: Unatic
  keyword to get the EXE name and the EXE path instead of parsing Command$(0) ? madscijr 8 1,159 07-22-2025, 08:35 PM
Last Post: hsiangch_ong
  Command$ issues eoredson 8 1,409 05-02-2025, 01:42 AM
Last Post: eoredson
  need help playing sound using certain parameters madscijr 0 401 04-01-2025, 03:52 PM
Last Post: madscijr
  Locate command on the ttf graphical screens Helium5793 5 726 03-09-2025, 05:47 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)