SNDPLAYCOPY
From QB64 Wiki
The _SNDPLAYCOPY statement copies a sound, plays it and automatically closes the copy using a handle parameter passed from _SNDOPEN or _SNDCOPY
- _SNDPLAYCOPY handle&[, volume!]
Description:
- 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 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 _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 _SNDPLAYFILE if the sound will be played often, reducing the burden on computer.
Example 1: Playing a sound at half volume.
_SNDPLAYCOPY applause&, 0.5
Example 2: Playing a song at random volumes.
chomp& = _SNDOPEN("chomp.wav", "VOL,SYNC") _SNDPLAYCOPY chomp&, 0.5 + RND * 0.49
See also: