1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 10:30:36 +00:00
QB64-PE/internal/help/_SNDBAL.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

103 lines
3.7 KiB
Plaintext

{{DISPLAYTITLE:_SNDBAL}}
The [[_SNDBAL]] statement attempts to set the balance or 3D position of a sound.
{{PageSyntax}}
: [[_SNDBAL]] {{Parameter|handle&}}[, {{Parameter|x!}}][, {{Parameter|y!}}][, {{Parameter|z!}}][, {{Parameter|channel&}}]]
{{Parameters}}
* ''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.
*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.
* 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}}
''Example 1:''
{{CodeStart}} '' ''
h& = {{Cl|_SNDOPEN}}("LOL.wav", "SYNC,VOL")
{{Cl|_SNDBAL}} h&, 1
{{Cl|_SNDPLAY}} h& '' ''
{{CodeEnd}}
''Example:'' Loading a sound after '''build 20170811/60''' - no need to specify "sound capabilities" in [[_SNDOPEN]].
{{CodeStart}}
s& = {{Cl|_SNDOPEN}}("song.ogg")
{{Cl|PRINT}} "{{Cl|READ}}Y"; s&
{{Cl|_SNDPLAY}} s&
{{Cl|_SNDLOOP}} s&
xleft = -1
xright = 1
DO
k$ = {{Cl|INKEY$}}
{{Cl|SELECT CASE}} k$
{{Cl|CASE}} "f"
xleft = xleft - 0.1
{{Cl|_SNDBAL}} s&, xleft, , , 1
{{Cl|CASE}} "g"
xleft = xleft + 0.1
{{Cl|_SNDBAL}} s&, xleft, , , 1
{{Cl|CASE}} "h"
xright = xright - 0.1
{{Cl|_SNDBAL}} s&, xright, , , 2
{{Cl|CASE}} "j"
xright = xright + 0.1
{{Cl|_SNDBAL}} s&, xright, , , 2
{{Cl|CASE}} "n"
volume = volume - 0.1
{{Cl|_SNDVOL}} s&, volume
{{Cl|CASE}} "m"
volume = volume + 0.1
{{Cl|_SNDVOL}} s&, volume
{{Cl|CASE}} "p"
{{Cl|_SNDPAUSE}} s&
{{Cl|CASE}} " "
{{Cl|_SNDPLAY}} s&
{{Cl|CASE}} "i"
{{Cl|PRINT}} {{Cl|_SNDPLAYING}}(s&)
{{Cl|PRINT}} {{Cl|_SNDPAUSED}}(s&)
{{Cl|SLEEP}}
{{Cl|CASE}} "b"
{{Cl|_SNDSETPOS}} s&, 110
{{Cl|CASE}} "l"
{{Cl|_SNDLIMIT}} s&, 10
{{Cl|PRINT}} "LIM"
{{Cl|SLEEP}}
{{Cl|CASE}} "k"
{{Cl|_SNDSTOP}} s&
{{Cl|CASE}} "c"
{{Cl|_SNDCLOSE}} s&
{{Cl|SLEEP}}
s2& = {{Cl|_SNDOPEN}}("song.ogg")
{{Cl|CASE}} "d"
s2& = {{Cl|_SNDCOPY}}(s&)
{{Cl|_SNDPLAY}} s2&
{{Cl|END SELECT}}
{{Cl|LOCATE}} 1, 1
{{Cl|PRINT}} xleft, xright, volume, {{Cl|_SNDGETPOS}}(s&); " "
LOOP
{{CodeEnd}}{{small|Code by Johny B}}
{{PageSeeAlso}}
*[[_SNDOPEN]], [[_SNDVOL]], [[_SNDLIMIT]]
{{PageNavigation}}
<