SDK 6.3/PAWN/Sound
Jump to navigation
Jump to search
Official WOWCube SDK documentation. SDK 6.3, PAWN API. Generated from the canonical SDK headers — do not edit by hand; regenerate from source.
Contents
Functions
SND_getAssetId
Syntax:
native SND_getAssetId(const name[]);
Description:
- Get a sound ID by the filename.
Arguments:
- name
- sound filename for which ID is requested
Return values:
- The ID of sound with a given filename or -1 in case of error.
See also: SND_play(), ON_Init()
History:
- v5.0 - renamed from SND_getId() to SND_getAssetId()
- v6.0 - truncate asset name in WASM API
SND_play
Syntax:
native SND_play(const id, const volume);
Description:
- Play sound by ID.
- Play any sound by its ID. Platform does not support audio mixing, so
- previously playing sound will be stopped if it has not yet finished.
- Supported audio formats:
- WAV
- MP3
- MIDI
Arguments:
- id
- an ID of sound to play
- volume
- volume of sound in percents to play, range 0..100
See also: SND_getAssetId()
SND_cacheSounds
Syntax:
native SND_cacheSounds(soundList[], size = sizeof(soundList));
Description:
- Force platform to cache application sounds.
- Platform automatically reads and caches sounds from flash when the
- application plays a sound. Flash operations are synchronous and may cause
- delays especially when reading large portions of data. To prevent the
- application from lags it is possible to cache sound data in advance.
- However if application requests to play a non-cached sound and there is not
- enough memory then oldest accessed sounds will be removed from cache. Also
- there is a limit of 256 for a total number of cached sounds.
Arguments:
- soundList
- array with IDs of sounds to cache
- size
- size of soundList array
Return values:
- Number of cached sounds or negative value if an error happened. Error
- codes:
- * -1 invalid function arguments count
- * -2 invalid soundList array
History:
- v5.0 - moved from appCtrl module to sound
SND_isPlaying
Syntax:
native bool:SND_isPlaying();
Description:
- Check if audio is playing.
Return values:
- True if audio is playing, false otherwise.
History:
- v6.0 - added
SND_stop
Syntax:
native SND_stop();
Description:
- Stop playing sound if any.
See also: SND_play()
History:
- v6.0 - added
SND_getAssetsCount
Syntax:
native SND_getAssetsCount();
Description:
- Get the total count of sound assets.
Return values:
- Number of sound assets.
History:
- v6.0 - added
PlayRandomSound
Syntax:
stock bool:PlayRandomSound(const snd[], const volume, const bool: stopPlaying = true, size = sizeof(snd))
Description:
- Play random sound from an array.
- Play random sound from an array.
Arguments:
- snd
- the array of sounds from which the sound will be selected
- volume
- sound volume
- stopPlaying
- stop sound playback if it is being played
- size
- size of the array snd
See also: PlayLoopRandomSound()
PlayLoopRandomSound
Syntax:
stock PlayLoopRandomSound(const snd[], const volume, const delayMin, const delayMax, dt, size = sizeof(snd))
Description:
- Play random sound from an array in a loop with a specified delay range.
- Play random sound from an array in a loop with a specified delay range.
Arguments:
- snd
- the array of sounds from which the sound will be selected
- volume
- sound volume
- delayMin
- minimum delay
- delayMax
- maximum delay
- dt
- delta time
- size
- size of the array snd
See also: PlayRandomSound()