09-06-2022, 02:44 AM
@Stuart It appears as if the culprit to your code being slower is because of the SOUND command -- and it seems as if the reason why it runs faster is because it's glitched in the old OpenAL backend!
Try this code for example:
Now here we're just printing a few dots onto the screen, while playing a sound. Our call to sound has it playing a C6 note for about 1/18th of a second. (SOUND's parameters are frequency, duration, and the duration is counted in 1/18th of seconds.) The result we would expect to see her should be 18 * 3 = 54 runs in 3 seconds.
On my PC, I'm seeing around 60 runs in 3 seconds with the new audio backend. We're actually running a little faster than we should, but it's not that much faster.
As for the old backend? This is running for 72,000+ times in 3 seconds, and our tone continues to play long after the program ends! It's definitely tossing out these sounds -- which should be a program pause in execution -- at an insane rate!!
The old audio backend is glitched rather badly, and it's just something which nobody ever noticed before. (Much like the issue with Ken's dancing line program -- all we ever got was mono-speaker sound, which worked for his program, and it wasn't until the new backend started producing stereo sound that the glitches in his code became apparent.)
The old version was indeed faster -- but it was insanely faster and broken. The new one fixes the issue the old one had, and that's where you're seeing the slowdown in your code from.
Try this code for example:
Code: (Select All)
t# = Timer + 3
Do
Sound 1000, 1
Print ".";
count = count + 1
Loop While Timer < t#
Print count; "runs in 3 seconds"
Now here we're just printing a few dots onto the screen, while playing a sound. Our call to sound has it playing a C6 note for about 1/18th of a second. (SOUND's parameters are frequency, duration, and the duration is counted in 1/18th of seconds.) The result we would expect to see her should be 18 * 3 = 54 runs in 3 seconds.
On my PC, I'm seeing around 60 runs in 3 seconds with the new audio backend. We're actually running a little faster than we should, but it's not that much faster.
As for the old backend? This is running for 72,000+ times in 3 seconds, and our tone continues to play long after the program ends! It's definitely tossing out these sounds -- which should be a program pause in execution -- at an insane rate!!
The old audio backend is glitched rather badly, and it's just something which nobody ever noticed before. (Much like the issue with Ken's dancing line program -- all we ever got was mono-speaker sound, which worked for his program, and it wasn't until the new backend started producing stereo sound that the glitches in his code became apparent.)
The old version was indeed faster -- but it was insanely faster and broken. The new one fixes the issue the old one had, and that's where you're seeing the slowdown in your code from.