Author Topic: Changes to sound output  (Read 932 times)

Johny B.

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1528
Changes to sound output
« on: August 11, 2017, 05:17:36 am »
This will be in revision 60, available on qb64.net sometime in the next few hours or right now on qb64.org

_SNDBAL now looks like this:
Code: [Select]
_SNDBAL handle&, x!, y!, z!, channel&If any of the x/y/z values are not passed they are unchanged. If channel& is omitted it defaults to 1 (the left channel for stereo sound, or the only channel for mono sound). To adjust the right channel of stereo sound use channel 2. All other values are invalid - but adjusting channel 2 for a mono sound will simply do nothing.

The default positions for sound sources are now as follows:
 - mono sound: (0, 0, 0)
 - stereo sound: left channel at (-1, 0, 0), right channel at (1, 0, 0)
This gives the results you would expect, with mono sound playing equally from both sides and stereo properly split.

_SNDVOL adjusts the volume of both channels. To make one channel quieter, just position it further away (I can't really imagine why you'd want to do that, though).

The second parameter to _SNDOPEN and concept of "sound capabilities" is gone. You no longer need to pass a string like "SYNC,PAUSE,VOL", as all sound formats support all abilities all the time. To avoid breaking existing code _SNDOPEN and _SNDPLAYFILE will still accept the capabilities string as an optional argument, but its contents will be ignored. This also means the concept of non-SYNC sounds and restrictions on playing simultaneous sounds is gone.

Please test, test, test. Wiki will be updated in the coming days to reflect changes. Finally, for your gratification, I've attached the program I was using to test things:
Code: [Select]
s& = _SNDOPEN("song.ogg")
PRINT "READY"; s&
_SNDPLAY s&
_SNDLOOP s&


xleft = -1
xright = 1
DO
    k$ = INKEY$
    SELECT CASE k$
        CASE "f"
            xleft = xleft - 0.1
            _SNDBAL s&, xleft, , , 1
        CASE "g"
            xleft = xleft + 0.1
            _SNDBAL s&, xleft, , , 1
        CASE "h"
            xright = xright - 0.1
            _SNDBAL s&, xright, , , 2
        CASE "j"
            xright = xright + 0.1
            _SNDBAL s&, xright, , , 2
        CASE "n"
            volume = volume - 0.1
            _SNDVOL s&, volume
        CASE "m"
            volume = volume + 0.1
            _SNDVOL s&, volume
        CASE "p"
            _SNDPAUSE s&
        CASE " "
            _SNDPLAY s&
        CASE "i"
            PRINT _SNDPLAYING(s&)
            PRINT _SNDPAUSED(s&)
            SLEEP
        CASE "b"
            _SNDSETPOS s&, 110
        CASE "l"
            _SNDLIMIT s&, 10
            PRINT "LIM"
            SLEEP
        CASE "k"
            _SNDSTOP s&
        CASE "c"
            _SNDCLOSE s&
            SLEEP
            s2& = _SNDOPEN("song.ogg")
        CASE "d"
            s2& = _SNDCOPY(s&)
            _SNDPLAY s2&
    END SELECT
    LOCATE 1, 1
    PRINT xleft, xright, volume, _SNDGETPOS(s&); "   "
LOOP

Clippy

  • Hero Member
  • *****
  • Posts: 19401
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Changes to sound output
« Reply #1 on: August 14, 2017, 03:58:26 am »
Opened sound files must have the "VOL" capability to use _SNDBAL so now what happens to files without that capability?

Why couldn't the channel parameter be used as 1 or 2 to designate the number of channels instead of having to use _SNDBAL twice?

Who is going to edit the WIKI as the old capabilities will still need to be documented for older versions?

 
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Johny B.

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1528
Re: Changes to sound output
« Reply #2 on: August 14, 2017, 05:23:13 am »
Opened sound files must have the "VOL" capability to use _SNDBAL so now what happens to files without that capability?
There are no capabilities. All sound files can do everything. Just open the file and use it.

Why couldn't the channel parameter be used as 1 or 2 to designate the number of channels instead of having to use _SNDBAL twice?
Your exact question as it stands makes no sense, so instead I'll answer "why require using _SNDBAL twice instead of setting both channels with one call?": This was initially considered (_SNDBAL handle&, xleft, yleft, zleft, xright, yright, zright) but it was pointed out that this was kind of bulky. The settled-upon syntax is much more concise and allows for future expansion to more than 2 channels (5 channel surround sound etc.)

Who is going to edit the WIKI as the old capabilities will still need to be documented for older versions?
I've prepared a list of changes for Steve, because frankly I don't have the mental strength to deal with you.

Clippy

  • Hero Member
  • *****
  • Posts: 19401
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Changes to sound output
« Reply #3 on: August 14, 2017, 06:59:15 am »
Well, poor mental strength or not, a  lot more sound files will need to be tested before anything is changed permanently. Like it or lump it...
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 6226
Re: Changes to sound output
« Reply #4 on: August 14, 2017, 07:38:09 am »
Well, poor mental strength or not, a  lot more sound files will need to be tested before anything is changed permanently. Like it or lump it...

It's already been changed permanently.  The changes were pushed into the repo on 8/11.  All builds from that date forward come with the new capabilities for sound files and multiple channel support.

Quote
Why couldn't the channel parameter be used as 1 or 2 to designate the number of channels instead of having to use _SNDBAL twice?

By sound channel, Luke is referring to a sound file which has multiple channels inside it.  For surround sound, a file may have 7+ channels stored inside it for LEFT FRONT, CENTER, RIGHT FRONT, MID-RANGE LEFT, MID-RANGE RIGHT, RIGHT REAR, LEFT REAR...

A user might have a program where they want all the sounds to come out equally from ALL the channels (my mother does this with her surround  sound as she's 80 years old and hard of hearing).  They may only have 2 speakers and want to move the rear channels to play in the front left and right speakers.  Various solutions for various people...

So the following was agreed upon:

_SNDBAL handle, x, y, z, channel   -- everything is the EXACT same as before, except now you can specify where you want a second channel to play from with your sound file.  (Think of a game where the footsteps echo from behind you.. Channel 1 is the main sound, channel 2 is the echo footfall..)

So if we have 2 speakers and a 5 sound channel file, we could do something like:

_SNDBAL handle, -1, , , 1 -- This puts the first channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the second channel to the right speaker
_SNDBAL handle, 0, , , 1 -- This splits the third channel between both left and right speaker
_SNDBAL handle, -1, , , 1 -- This puts the fourth channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the fifth channel to the right speaker
http://bit.ly/Color32BI -- A set of color CONST for use in 32 bit mode, as a BI library.

Mal-2

  • Full Member
  • ***
  • Posts: 126
Re: Changes to sound output
« Reply #5 on: August 14, 2017, 11:45:33 pm »
_SNDBAL handle, -1, , , 1 -- This puts the first channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the second channel to the right speaker
_SNDBAL handle, 0, , , 1 -- This splits the third channel between both left and right speaker
_SNDBAL handle, -1, , , 1 -- This puts the fourth channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the fifth channel to the right speaker

I think you meant:
_SNDBAL handle, -1, , , 1
_SNDBAL handle, 1, , , 2
_SNDBAL handle, 0, , , 3
_SNDBAL handle, -1, , , 4
_SNDBAL handle, 1, , , 5

But the point still stands.
Please excuse my spaghetti code. Music is my real job, mal-2.bandcamp.com and whitemice.bandcamp.com (though I also write).
When Chuck Norris throws an exception, it is always fatal.

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 6226
Re: Changes to sound output
« Reply #6 on: August 15, 2017, 02:38:09 am »
_SNDBAL handle, -1, , , 1 -- This puts the first channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the second channel to the right speaker
_SNDBAL handle, 0, , , 1 -- This splits the third channel between both left and right speaker
_SNDBAL handle, -1, , , 1 -- This puts the fourth channel to the left speaker
_SNDBAL handle, 1, , , 1 -- This puts the fifth channel to the right speaker

I think you meant:
_SNDBAL handle, -1, , , 1
_SNDBAL handle, 1, , , 2
_SNDBAL handle, 0, , , 3
_SNDBAL handle, -1, , , 4
_SNDBAL handle, 1, , , 5

But the point still stands.

Aye.  Sorry; I was lazy and did a copy/paste and didn't change the channel parameter.  Good catch.  :D
http://bit.ly/Color32BI -- A set of color CONST for use in 32 bit mode, as a BI library.

Clippy

  • Hero Member
  • *****
  • Posts: 19401
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Changes to sound output
« Reply #7 on: August 15, 2017, 06:45:44 am »
Steve WTF do you think you are doing? You cannot just remove old descriptions from the WIKI! They are needed for SDL and older versions!

Also you changed _SNDBAL and never mentioned the new channel parameter values such as 3,4, or 5
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

Johny B.

  • QB64 Partner Site Owner
  • Hero Member
  • *
  • Posts: 1528
Re: Changes to sound output
« Reply #8 on: August 15, 2017, 06:54:25 am »
To quote myself:
Quote
To adjust the right channel of stereo sound use channel 2. All other values are invalid
Higher channel numbers may become available in a future version of QB64.

Quote
You cannot just remove old descriptions from the WIKI! They are needed for SDL and older versions!
This bullshit is precisely the reason I didn't want to have to deal with you. The wiki documents QB64 as it is, not how it was 5 years ago. Keep your fingers off of my documentation, Ted.

Clippy

  • Hero Member
  • *****
  • Posts: 19401
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Changes to sound output
« Reply #9 on: August 15, 2017, 07:13:01 am »
The WIKI must document all versions, not just the latest version.

ANY ADDITIONS must also specify the new version info with the date they became effective.

REMOVING PREVIOUS INFO IS GROUNDS TO LOSE EDITING PRIVILEGES
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 6226
Re: Changes to sound output
« Reply #10 on: August 15, 2017, 07:36:35 am »
The WIKI must document all versions, not just the latest version.

ANY ADDITIONS must also specify the new version info with the date they became effective.

REMOVING PREVIOUS INFO IS GROUNDS TO LOSE EDITING PRIVILEGES

There's no need for the wiki to continue to be full of useless crap which dates back to the SDL days.   Galleon has dropped ALL support for the SDL version, or did you forget?  http://www.qb64.net/forum/index.php?topic=12479.msg107737#msg107737

Quote
I will be discontinuing all support for the SDL version of QB64 at qb64.net on Feb 1st 2015. All downloads (official and unofficial) for QB64-SDL will be removed. The reason is simple. QB64 cannot afford to have its development/support efforts split across multiple versions.

If you feel passionately about this, let me remind you that QB64-SDL (like QB64-GL) is open source and you are entitled to host and/or continue its development off-site if you so wish.

The changes removed applied to SDL versions of QB64.  "VOL,SYNC,LEN,PAUSE" requirements have been obsolete ever since the switch over to the GL version -- just nobody noticed before now!!   

The following is COMPLETELY wrong:
Quote
             WAV = "VOL,SYNC,LEN,PAUSE"      Free WAV to OGG GUI converter
             OGG = "VOL,SYNC,LEN,PAUSE"      Free WAV to OGG converter
             AIF = "VOL,SYNC,LEN,PAUSE"
             RIF = "VOL,SYNC,LEN,PAUSE"
             VOC = "VOL,SYNC,LEN,PAUSE"
             MID = "VOL"
             MOD = "VOL,PAUSE"
             MP3 = "VOL,PAUSE,SETPOS" 

GL only supports three sound types:  WAV, OGG, MP3 -- and it supports ALL the options for ALL those formats.

Confusing people with SDL requirements, and claiming that we offer support for formats -- when we plainly do NOT -- is NOT a good means of documenting the wiki.

SDL crap has to go!!  Support for SDL has been OFFICIALLY dropped, and the junk you're leaving in the wiki is nothing more than that -- JUNK to confuse people about what the behavior of the commands in GL really is.


QB64 cannot afford to have its development/support efforts split across multiple versions.

The wiki *is* the official support effort, and it doesn't need to be split across multiple versions.
http://bit.ly/Color32BI -- A set of color CONST for use in 32 bit mode, as a BI library.

Clippy

  • Hero Member
  • *****
  • Posts: 19401
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Changes to sound output
« Reply #11 on: August 15, 2017, 08:56:49 am »
http://www.qb64.net/wiki/index.php/SNDBAL

SDL is not the only version affected! There are thousands of older GL versions IN USE!

3 sound file versions is more of a limitation than an improvement...

Let me know what else needs to be documented.

You can document on your own sites as well...
« Last Edit: August 15, 2017, 09:09:57 am by Clippy »
QB64 WIKI: Main Page
Download Q-Basics Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
QB64 SDL

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 6226
Re: Changes to sound output
« Reply #12 on: August 15, 2017, 12:36:08 pm »
http://www.qb64.net/wiki/index.php/SNDBAL

SDL is not the only version affected! There are thousands of older GL versions IN USE!

3 sound file versions is more of a limitation than an improvement...

Umm....   Have you tried to use any sound format other than WAV, OGG, MP3 in the last few years??  The recent changes hasn't caused any of the others to stop functioning; support for them was never implemented (just like how _LOADIMAGE no longer loads 256 color images).

Sound capabilities such as "VOL, LEN, and all" have had ZERO affect since the first GL version was introduced.  They do literally NOTHING. 

(Well, there was a BUG which basically made VOL not work unless the flag was set, but that's been corrected.  If folks encounter VOL issues, then they just need to upgrade to the newer builds where the problem was corrected.)
http://bit.ly/Color32BI -- A set of color CONST for use in 32 bit mode, as a BI library.

SkyCharger001

  • Hero Member
  • *****
  • Posts: 2399
Re: Changes to sound output
« Reply #13 on: August 15, 2017, 04:28:50 pm »
Mayor problem: the GL versions suffer from a (for many) crippling bug in how keyboard input is handled that doesn't exist in the SDL versions, with the only 'fix' being offered is the productivity-destroying abandon US-international.

SMcNeill

  • Moderator
  • Hero Member
  • *****
  • Posts: 6226
Re: Changes to sound output
« Reply #14 on: August 15, 2017, 07:46:51 pm »
Mayor problem: the GL versions suffer from a (for many) crippling bug in how keyboard input is handled that doesn't exist in the SDL versions, with the only 'fix' being offered is the productivity-destroying abandon US-international.

Post a bug report on it and include a bit of code to highlight what the issue is.  Be certain to explain how the changes to sound output affected keyboard input.  First I've heard of any keyboard issues from this change.

http://bit.ly/Color32BI -- A set of color CONST for use in 32 bit mode, as a BI library.