Skip to main content
reskate.audio plays two kinds of sound. play_ui plays one of the game’s menu sounds and needs the audio.ui permission. play, set, stop and playing play your plugin’s own WAV files, or a synthesised motor, at a place in the level, and need audio.

reskate.audio.play_ui(name)

Plays one of the game’s menu sounds, as its own menus do.
string
required
"select", "cancel", "navigate", "toggle" or "tab".
boolean
true when it played; false past 10 menu sounds in a second.
Needs audio.ui. At most 10 a second; past them it returns false. Raises an error for a name that is not one of the five.

Your own sounds

Your sounds play through the game’s positioned sound, the one other players’ voices use, so the level’s mix and echo apply. They play only in a level: out of one, play fails, and leaving a level ends every sound playing. How loud a sound is depends on how far it is from the camera: it is at its volume at the camera and fades to silence at range metres.

Sound files

A sound is a WAV file in your package:
  • RIFF WAVE, 8, 16, 24 or 32-bit PCM, or 32-bit float;
  • 1 to 8 channels, 4,000 to 192,000 samples a second;
  • at most 30 seconds long, and at most 8 MB.
ReSkate turns it into 16 kHz mono when it first plays it (channels are mixed down). A plugin plays at most 32 different files in all; each is read once and kept.

reskate.audio.play(sound, options)

Starts a sound and returns its id.
string
required
A WAV file’s path in your package (see package paths), at most 200 characters, or "motor" for a synthesised motor: four rotors and a rush of wind, whose note follows throttle and wind follows speed.
table
The sound’s options, below. Every one is optional.
number or false
The sound’s id, for set, stop and playing; or false when it could not start.
string
Why not, when id is false: “more than 20 sounds in a second”, or “it plays 8 sounds already, or there is no level”.

Options

A number outside its range raises an error (“volume is 0 to 1”).
Needs audio. A plugin plays at most 8 sounds at once (and all plugins 48), and starts at most 20 in a second; past those, it returns false and why. Raises an error for a file that is not in the package, cannot be read, is not a WAV it can play or is longer than 30 seconds, for a 33rd different file, and for an option out of its range.

reskate.audio.set(id, options)

Changes a sound while it plays.
number
required
What play returned.
table
Any of volume, pitch, range, throttle, speed and position, with the ranges above. Options you leave out keep their values. loop cannot be changed.
boolean
true when it was changed; false when the sound has finished, was stopped, or is not this plugin’s.
Needs audio. Raises an error for an id that is not a whole number of 1 or more, and for an option out of its range.

reskate.audio.stop(id)

Stops a sound. It goes silent at once. A sound that has finished, or is not this plugin’s, is ignored.
number
required
What play returned.
Needs audio.

reskate.audio.playing(id)

Whether a sound still plays.
number
required
What play returned.
boolean
true while it plays; false once a WAV that does not loop has played out, after stop, after leaving the level, or for a sound that is not this plugin’s.
Needs audio.
For a sound every player hears, send a message and let each player’s copy of your plugin play it: a sound plays only on the game that started it.