audio, skater.read and console permissions. Every function is on the audio page.
reskate.audio.play is for sounds in the level. The game’s own menu sounds (select, cancel, navigate, toggle, tab) are reskate.audio.play_ui, with the audio.ui permission.How plugin sounds play
A plugin’s sounds play through the game’s positioned voice sound, as other players’ voices do, so the level’s mix, echo and walls apply to them. Each sound is at a place in the world, or at the local skater, and is heard from the camera: it gets quieter with distance and is silent at itsrange.
Sounds play in a level only. Out of one, play returns false and "it plays 8 sounds already, or there is no level", and leaving a level ends every sound playing. They play on this player’s game only: nothing is sent to other players.
1. The package
2. Play a WAV
reskate.audio.play(path, options) starts one of the package’s WAV files and returns its id, a number. It returns false and why when it cannot start one: the plugin plays 8 sounds already (or all plugins together play 48), or it started more than 20 in the last second.
position, the sound plays at the local skater and follows it. A file that is not there, is not a WAV, or is too long raises an error, as does a path outside the package.
The options, all optional:
A value outside its range raises an error. Up close a sound plays at its
volume, and it falls off with the square of the distance: at a distance d, it plays at volume times (1 - d / range) squared.
3. Leave a sound somewhere
Give a sound aposition and it stays there while the skater moves away. A looping radio, left where the skater stands:
4. The motor synth
Pass"motor" in place of a path and the sound is a synthesised motor: four rotors and a rush of wind, as the fpv-drone plugin’s. throttle sets how fast it spins (its pitch rises with it, spinning up and down over about 80 ms), speed adds the wind (full at 60 m/s), and pitch scales its note. The motor plays until it is stopped: loop makes no difference to it.
5. Change it each tick
reskate.audio.set(id, options) changes a sound while it plays: any of volume, pitch, range, throttle, speed and position (loop is set only when it starts). It returns true, or false once the sound has ended. Set it from the tick handler to move it and change it smoothly.
Here the motor circles the skater 3 m out and 1.5 m up, and revs with the skater’s speed:
position = "skater" in set puts a sound back on the skater.
6. Stop it
reskate.audio.stop(id) stops a sound, and an id that is not playing is ignored. reskate.audio.playing(id) says whether it still plays: a WAV that is not looped ends on its own.
Stop your sounds when what they belong to ends. Sounds end by themselves out of a level, and every sound a plugin plays stops when it stops or unloads, but keep your own state in step:
A plugin plays at most 8 sounds at once (48 for all plugins together), starts at most 20 a second, and plays at most 32 different files. See limits.