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?
#11
(08-05-2022, 02:42 PM)bplus Wrote: But I think you CAN control how long Sounds are made, so don't make next sound until ready for it, be a clock watcher.

I thought of this too, and it's a reasonable workaround. 

Still, in the spirit of BASIC being easy, I think SOUND(0,0) ought to be fixed! LoL

And there should be a "stop" command for SNDRAW that just clears that buffer and stops playing sound. 

I have no idea how hard these would be for the QB64 devs to implement. Are either of these trivial, or are we talking some involved stuff? I'm just wondering, no expectations.

For the current case, using _SndPlay / _SndLoop / _SndStop with a WAV file will work for me. 

Later I plan on learning to generate the WAV files from code, that will be a fun project!
Reply
#12
Sound is very old and primitive like Screen 0. Time well spent learning more modern methods.

Dont hold your breath for any changes to Sound, its probably just there for old programs.
b = b + ...
Reply
#13
(08-05-2022, 02:42 PM)bplus Wrote: But I think you CAN control how long Sounds are made, so don't make next sound until ready for it, be a clock watcher.

I hate to be a clock blocker... Ah, let me rephrase that....

Okay, there are two different conditions to be considered here, sound you can code appropriately to finish at a given elapsed time, and sound that needs to be shut off at a random time or upon a user controlled event. The later appears to be the condition being addressed in this thread, so timing the sound wouldn't be a solution.

Another funny Mickey Mouse Windows solution would be to have the event use a _SENDKEY routine in Windows API to emulate a function F1 key input, which would MUTE the speakers! Of course you you had to get the speakers back on for the next event before the buffer emptied, you'd still b screwed. That's why I was hoping Spriggsy might have an API solution that would clear the buffer. Still, that would not address the same problem in Mac or Linux.

If this wasn't very complicated, I'm pretty sure Galleon, Fill, or luke would have tackled it years ago. High complexity low priority... well, low priority until it's your program that needs it, that is.

Pete

Edit: > "Sound is very old and primitive like Screen 0." Them's fightin' words, varmint!
Reply
#14
"Edit: > "Sound is very old and primitive like Screen 0." Them's fightin' words, varmint!"

Inserted just for this response! LOL

Actually I like working with minimal tools, forces creativity, so getting sound to work by timing out code execution SOUNDs like an excellent challenge!!!

Plus! No licensing worries!
b = b + ...
Reply
#15
Big GrinBig GrinBig Grin
Shoot first and shoot people who ask questions, later.
Reply
#16
Really, why couldn't you check for user keypresses or mouse-clicks before releasing next sound, piece of cake compared to writing code for User Defined Functions for an Esoteric Interpreter.
b = b + ...
Reply
#17
(08-05-2022, 04:47 PM)Pete Wrote:
(08-05-2022, 02:42 PM)bplus Wrote: But I think you CAN control how long Sounds are made, so don't make next sound until ready for it, be a clock watcher.

I hate to be a clock blocker... Ah, let me rephrase that....

Okay, there are two different conditions to be considered here, sound you can code appropriately to finish at a given elapsed time, and sound that needs to be shut off at a random time or upon a user controlled event. The later appears to be the condition being addressed in this thread, so timing the sound wouldn't be a solution.

Another funny Mickey Mouse Windows solution would be to have the event use a _SENDKEY routine in Windows API to emulate a function F1 key input, which would MUTE the speakers! Of course you you had to get the speakers back on for the next event before the buffer emptied, you'd still b screwed. That's why I was hoping Spriggsy might have an API solution that would clear the buffer. Still, that would not address the same problem in Mac or Linux.

If this wasn't very complicated, I'm pretty sure Galleon, Fill, or luke would have tackled it years ago. High complexity low priority... well, low priority until it's your program that needs it, that is.

Pete

Edit: > "Sound is very old and primitive like Screen 0." Them's fightin' words, varmint!

Thanks for spinning your wheels on this! 
The problem is that I would just want to stop the specific sound created by the SOUND command, with other currently playing sounds (done with _SndPlay) still audible. 
A fun little puzzle to puzzle over, eh?
Reply
#18
(08-05-2022, 04:33 PM)bplus Wrote: Sound is very old and primitive like Screen 0. Time well spent learning more modern methods.

Dont hold your breath for any changes to Sound, its probably just there for old programs. 

Ha! I get all that, but allow me to argue a point... 

We do have a more modern method, _SndPlay works fine for playing sounds and stopping them whenever we want. BUT you can't control pitch or choose a different waveform on the fly. 

If for that, by more modern methods, we mean _SNDRAW, I don't know if I'd call it modern so much as manual! LoL

It shouldn't be so hard to say play me a MyPitch% Hz sine wave until I send the "Stop" command, should it? Especially in BASIC! My TI99/4A could do it in 1983, and a kid could understand it, without having to know the details the WAV file specification or do crazy stuff with timers or other difficult methods. 

Just saying!  Smile
Reply
#19
(08-05-2022, 06:11 PM)bplus Wrote: Really, why couldn't you check for user keypresses or mouse-clicks before releasing next sound, piece of cake compared to writing code for User Defined Functions for an Esoteric Interpreter.

Alas this doesn't apply in the situation it came out of. 
Some action happens, like an alien flies across the screen, making some crazy sound created with fancy SOUND statements, and then it flies off the screen. But the sound keeps playing... 
The game action continues, other sounds are happening, the user is still pressing keys. 
Why must we still hear that alien? 

We can use _sndPlay which does not have this problem. 
But to get sounds that are made up on the fly - for example if we want the pitch to be based off some in-game logic or state, we either need to have created the sound files for each pitch ahead of time, or use _sndRaw or create a WAV file on the fly. Not so easy! 

I do plan on learning more about those methods BTW! If I figure it out, then maybe I can create some commands to make this kind of control easier for a less technical programmer (starting with myself! lol)
Reply
#20
You give aliens too much to yap about, remember that kind of air time belongs only to William Shatner! Who keeps on going... and going... and going...
b = b + ...
Reply




Users browsing this thread: 4 Guest(s)