09-06-2022, 05:49 PM
(09-06-2022, 04:43 AM)SMcNeill Wrote: IF snd AND D! > 0 THEN
SOUND Hz, D! + .4 * -(D! = 0)
You may want to rework your duration for your SOUND statement. D is greater than 0, so D can never BE zero in your formula, making the D = 0 FALSE
SOUND Hz, D + .4 * -(D = 0)
SOUND Hz, D + .4 * -0
SOUND Hz, D
I don't know what D is in your program, but you may want to tweak it for the new backend where our timing is much closer to what's expected. Maybe try SOUND Hz, D / 10
Okay, D! is used to denote the duration of the sound.
Although the help files for QB64 _and_ QB4.5 say that "DURATION" should be an INTEGER value, I've found that it also seems to work properly with a duration as small as .1 for QB64 and .4 for QB4.5 and the sounds do seem to be shorter than with a duration of 1.
Now, D! will be equal to zero when sound events are turned off, so in order to make a sound when the sound events are turned back on I added the " + .4 * -(D! = 0) ", and I also enter the subroutine at 5556 instead of 5555 when turning sound events on or off in order to avoid the test for D! > 0.
As far as the "DURATION" value goes, I plan to recheck everything in QB64 and QB4.5 and make any adjustments needed for the best results.
QB4.5 always uses the "SOUND" command; QB64 uses the "SOUND" command _only_ if the .wav files aren't present when the program is compiled.
Thanks again @SMcNeill for all your help and advice.