mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-20 09:04:44 +00:00
47 lines
1.2 KiB
Text
47 lines
1.2 KiB
Text
|
The {{KW|_SNDPLAYCOPY}} statement copies a sound, plays it and automatically closes the copy using a handle parameter passed from {{KW|_SNDOPEN}} or {{KW|_SNDCOPY}}
|
||
|
|
||
|
|
||
|
{{PageSyntax}}
|
||
|
:{{KW|_SNDPLAYCOPY}} {{Parameter|handle&}}[, {{Parameter|volume!}}]
|
||
|
|
||
|
|
||
|
|
||
|
{{PageDescription}}
|
||
|
* Opened sound files must have the "SYNC" capability to use this statement. (Currently WAV, OGG, AIF, RIF and VOC)
|
||
|
* The volume parameter can be any {{KW|SINGLE}} value from 0 (no volume) to 1 (full volume).
|
||
|
*Makes coding easier by doing all of the following automatically:
|
||
|
:#Copies/duplicates the source handle (see {{KW|_SNDCOPY}})
|
||
|
:#Changes the volume of the copy if volume is passed (file must have "VOL" capability)
|
||
|
:#Plays the copy
|
||
|
:#Closes the copy
|
||
|
* This statement is a better choice than {{KW|_SNDPLAYFILE}} if the sound will be played often, reducing the burden on computer.
|
||
|
|
||
|
|
||
|
''Example 1:'' Playing a sound at half volume.
|
||
|
|
||
|
{{CodeStart}}
|
||
|
|
||
|
{{Cl|_SNDPLAYCOPY}} applause&, 0.5
|
||
|
|
||
|
{{CodeEnd}}
|
||
|
|
||
|
|
||
|
''Example 2:'' Playing a song at random volumes.
|
||
|
|
||
|
{{CodeStart}}
|
||
|
|
||
|
chomp& = _SNDOPEN("chomp.wav", "VOL,SYNC")
|
||
|
|
||
|
_SNDPLAYCOPY chomp&, 0.5 + RND * 0.49
|
||
|
|
||
|
{{CodeEnd}}
|
||
|
|
||
|
|
||
|
|
||
|
{{PageSeeAlso}}
|
||
|
|
||
|
*{{KW|_SNDOPEN}}
|
||
|
*{{KW|_SNDCOPY}}
|
||
|
|
||
|
|
||
|
{{PageNavigation}}
|