QB64 Phoenix Edition
Feature Request - SOUND breaks on/off - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Feature Request - SOUND breaks on/off (/showthread.php?tid=2423)



Feature Request - SOUND breaks on/off - Abazek - 02-05-2024

Could you add a function or statement that would turn on/off the brief break (silence) after a SOUND command?  You could have this ON by default, so things wouldn't be any different than they are now.  But, if the programmer wanted to, they could turn this OFF, to make old style SOUNDs not be so "buzzy".  Maybe something like _SoundBreakOn and _SoundBreakOff or perhaps _SoundBreak(x) where x could be 1 or 0.

As an example, try running this code in QBasic (DosBox), in QB64PE 3.6, and the current (at the time of this writing) QB64PE 3.11.
Notice the difference in sound quality for each.  In QBasic it is loud and clear.  In 3.6 it is slightly buzzy/clicky.  In 3.11 it is VERY buzzy.

Code: (Select All)
For w = 1 To 3
    For q = 100 To 2000 Step 10
        Sound q, .2
    Next q
    For q = 2010 To 110 Step -10
        Sound q, .2
    Next q
Next w
End

There is an old game I started but never finished back in the 1990's (in QBasic), that I have started to work on again in QB64PE.  It has a lot of "retro video game" style sounds that do things similar to the code above.  I've been compiling it with QB64PE 3.6 because in newer versions the sound quality is TERRIBLE, but in 3.6 it is decent.  I would much rather use the current version (QB64PE 3.11), the only thing stopping me from doing that is the poor/buzzy sound quality.

If there was a command like _SoundBreakOff that I could add to the start of my program, which would make the sound work as it does in 3.6 (or better yet, if it is at all possible, as it does in QBasic), I would be able to use the current version, which would be fantastic!!

Thanks so much for QB64PE - you all are doing some amazing work!!


RE: Feature Request - SOUND breaks on/off - Abazek - 02-05-2024

UPDATE:  I found a solution.  I was tinkering around with the sample code found in the QB64PE Wiki entry for the SOUND statement, and I found a statement that does what I want:  PLAY "Q0"
This sets "volume ramping" to a value in milliseconds.  I didn't know this would also effect SOUND statements (I thought it was only for PLAY statements).  But then I saw this used in the "sound effects" sample code. When you set it to zero, it turns off the Sound Break (like I mentioned above) and completely gets rid of the buzzing!

Add a PLAY "Q0" to my above code, and the sound will play as it does in QBasic (which is even better than how it plays in QB64PE 3.6!!).  No buzzes/clicks at all.  Try the code below in QB64PE 3.11 and compare the sound quality to QBasic in DosBox (you'll need to remove or comment-out the PLAY "Q0" for QBasic):

Code: (Select All)

Play "Q0"
For w = 1 To 3
    For q = 100 To 2000 Step 10
        Sound q, .2
    Next q
    For q = 2010 To 110 Step -10
        Sound q, .2
    Next q
Next w
End

I will now be able to compile my old game using the current QB64PE version. Just need to add a PLAY "Q0" to it.

Again, thanks for the work you all have put into QB64PE.  This is fantastic!!


RE: Feature Request - SOUND breaks on/off - a740g - 02-05-2024

You are welcome.  Smile

Try the extended SOUND features like volume, panning and waveform as well -  SOUND - QB64 Phoenix Edition Wiki.


RE: Feature Request - SOUND breaks on/off - NakedApe - 02-05-2024

SOUND still pauses program execution when called though, right? This caused some weird blips and pauses in my early games before someone here pointed this out to me.


RE: Feature Request - SOUND breaks on/off - a740g - 02-05-2024

(02-05-2024, 04:18 PM)NakedApe Wrote: SOUND still pauses program execution when called though, right? This caused some weird blips and pauses in my early games before someone here pointed this out to me.

Yes - by default.

However, you can let SOUND play in the background by executing PLAY "MB" before using any SOUND statements.

If you are using SOUND to make sound effects (like Abazek), then you are probably better off turning off volume ramping as well by executing PLAY "Q0" before using any SOUND statements.

Both PLAY commands need to be executed only once and remains in effect until the end of the program or until it is changed.


RE: Feature Request - SOUND breaks on/off - NakedApe - 02-05-2024

Very cool. Good to know. Thanks!


RE: Feature Request - SOUND breaks on/off - TerryRitchie - 02-05-2024

(02-05-2024, 09:09 PM)a740g Wrote:
(02-05-2024, 04:18 PM)NakedApe Wrote: SOUND still pauses program execution when called though, right? This caused some weird blips and pauses in my early games before someone here pointed this out to me.

Yes - by default.

However, you can let SOUND play in the background by executing PLAY "MB" before using any SOUND statements.

If you are using SOUND to make sound effects (like Abazek), then you are probably better off turning off volume ramping as well by executing PLAY "Q0" before using any SOUND statements.

Both PLAY commands need to be executed only once and remains in effect until the end of the program or until it is changed.
Yes, very cool. I was unaware that PLAY parameters would also affect the SOUND statement. I need to do some updating to the sound and music tutorial lesson.