1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-03 10:01:21 +00:00
qb64/internal/help/_SNDBAL.txt

102 lines
3.7 KiB
Plaintext
Raw Normal View History

2016-03-18 11:36:04 +00:00
{{DISPLAYTITLE:_SNDBAL}}
The [[_SNDBAL]] statement attempts to set the balance or 3D position of a sound.
{{PageSyntax}}
2017-10-10 14:55:21 +00:00
: [[_SNDBAL]] {{Parameter|handle&}}[, {{Parameter|x!}}][, {{Parameter|y!}}][, {{Parameter|z!}}][, {{Parameter|channel&}}]]
{{PageParameters}}
2017-10-10 14:55:21 +00:00
* ''handle&'' is a valid sound handle created by the [[_SNDOPEN]] function.
* {{Parameter|x!}} distance values go from left (negative) to right (positive).
* {{Parameter|y!}} distance values go from below (negative) to above (positive).
* {{Parameter|z!}} distance values go from behind (negative) to in front (positive).
* {{Parameter|channel&}} value 1 denotes left (mono) and 2 denotes right (stereo) channel (beginning with '''build 20170811/60''')
{{PageDescription}}
*Attempts to position a sound in 3D space, or as close to it as the underlying software libraries allow. In some cases, this will be true 3D positioning, in others, a mere volume adjustment based on distance alone.
2017-10-10 14:55:21 +00:00
*Omitted x!, y! or z! [[SINGLE]] values are set to 0 or not changed in '''build 20170811/60 onward'''.
*By setting the x! value to -1 or 1 it plays the sound at full volume from the appropriate speaker.
*Sounds at a distance of 1 or -1 are played at full volume. Sounds further than a distance of 1000 cannot be heard.
*The volume decreases linearly (at a constant gradient) over distance. Half volume = 500.
2019-04-15 01:15:33 +00:00
* An "'''Illegal Function Call'''" error can occur if another sound is using the primary or same channel position.
* Opened sound files must have the [[_SNDOPEN|"VOL"]] capability to use this statement in versions '''before build 20170811/60.'''
{{PageExamples}}
2017-10-10 14:55:21 +00:00
''Example 1:''
{{CodeStart}} '' ''
2019-04-15 01:15:33 +00:00
h& = {{Cl|_SNDOPEN}}("LOL.wav", "SYNC,VOL")
{{Cl|_SNDBAL}} h&, 1
{{Cl|_SNDPLAY}} h& '' ''
{{CodeEnd}}
2019-04-15 01:15:33 +00:00
''Example:'' Loading a sound after '''build 20170811/60''' - no need to specify "sound capabilities" in [[_SNDOPEN]].
2017-10-10 14:55:21 +00:00
{{CodeStart}}
2019-04-15 01:15:33 +00:00
s& = {{Cl|_SNDOPEN}}("song.ogg")
{{Cl|PRINT}} "{{Cl|READ}}Y"; s&
2017-10-10 14:55:21 +00:00
{{Cl|_SNDPLAY}} s&
{{Cl|_SNDLOOP}} s&
xleft = -1
xright = 1
DO
k$ = {{Cl|INKEY$}}
{{Cl|SELECT CASE}} k$
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "f"
2017-10-10 14:55:21 +00:00
xleft = xleft - 0.1
{{Cl|_SNDBAL}} s&, xleft, , , 1
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "g"
2017-10-10 14:55:21 +00:00
xleft = xleft + 0.1
{{Cl|_SNDBAL}} s&, xleft, , , 1
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "h"
2017-10-10 14:55:21 +00:00
xright = xright - 0.1
{{Cl|_SNDBAL}} s&, xright, , , 2
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "j"
2017-10-10 14:55:21 +00:00
xright = xright + 0.1
{{Cl|_SNDBAL}} s&, xright, , , 2
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "n"
2017-10-10 14:55:21 +00:00
volume = volume - 0.1
{{Cl|_SNDVOL}} s&, volume
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "m"
2017-10-10 14:55:21 +00:00
volume = volume + 0.1
{{Cl|_SNDVOL}} s&, volume
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "p"
2017-10-10 14:55:21 +00:00
{{Cl|_SNDPAUSE}} s&
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} " "
2017-10-10 14:55:21 +00:00
{{Cl|_SNDPLAY}} s&
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "i"
2017-10-10 14:55:21 +00:00
{{Cl|PRINT}} {{Cl|_SNDPLAYING}}(s&)
{{Cl|PRINT}} {{Cl|_SNDPAUSED}}(s&)
{{Cl|SLEEP}}
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "b"
2017-10-10 14:55:21 +00:00
{{Cl|_SNDSETPOS}} s&, 110
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "l"
2017-10-10 14:55:21 +00:00
{{Cl|_SNDLIMIT}} s&, 10
2019-04-15 01:15:33 +00:00
{{Cl|PRINT}} "LIM"
2017-10-10 14:55:21 +00:00
{{Cl|SLEEP}}
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "k"
2017-10-10 14:55:21 +00:00
{{Cl|_SNDSTOP}} s&
2019-04-15 01:15:33 +00:00
{{Cl|CASE}} "c"
2017-10-10 14:55:21 +00:00
{{Cl|_SNDCLOSE}} s&
{{Cl|SLEEP}}
2019-04-15 01:15:33 +00:00
s2& = {{Cl|_SNDOPEN}}("song.ogg")
{{Cl|CASE}} "d"
2017-10-10 14:55:21 +00:00
s2& = {{Cl|_SNDCOPY}}(s&)
{{Cl|_SNDPLAY}} s2&
{{Cl|END SELECT}}
{{Cl|LOCATE}} 1, 1
2019-04-15 01:15:33 +00:00
{{Cl|PRINT}} xleft, xright, volume, {{Cl|_SNDGETPOS}}(s&); " "
2017-10-10 14:55:21 +00:00
LOOP
{{CodeEnd}}{{small|Code by Johny B}}
{{PageSeeAlso}}
2017-10-10 14:55:21 +00:00
*[[_SNDOPEN]], [[_SNDVOL]], [[_SNDLIMIT]]
2019-04-15 01:15:33 +00:00
{{PageNavigation}}