Audio Class
Layer which handles the Lua-facing side of loading and playing audio.
Method Index
- cacheSoundFilenamesAssociatedWithName(name)
- clearCallbacks()
- destroy()
- dumpSoundArchive(out_dir)
- entityNoLongerWaitingForSoundsToBeTurnedOn(entity)
- entitySoundsHandler(sounds, entity, silences, silences_pointer)
- findIndexOfCurrentTrack()
- getFileData(index)
- getMidiApiList()
- getMidiPortList()
- init()
- initMidiPlayer()
- initSpeech(speech_file)
- isPlaying(sound)
- isPlayingWithMidiPlayer()
- notifyJukebox()
- onEndPause()
- onMusicOver()
- onSoundPlayed(played_callbacks_id)
- pauseBackgroundTrack()
- playBackgroundTrack(index)
- playEntitySounds(names, entity, min_silence_lengths, max_silence_lengths, num_silences)
- playNextBackgroundTrack()
- playNextOrPreviousBackgroundTrack(direction)
- playPreviousBackgroundTrack()
- playRandomBackgroundTrack()
- playSound(name, where, is_announcement, played_callback, played_callback_delay, loops)
- playSoundEffects(play_effects)
- readPlaylistPreferences()
- releaseChannel(channel)
- reserveChannel()
- resolveFilenameWildcard(name)
- setAnnouncementVolume(volume)
- setBackgroundVolume(volume)
- setSoundStage()
- setSoundVolume(volume)
- soundExists(sound)
- stopBackgroundTrack()
- stopSound(sound)
- tellInterestedEntitiesTheyCanNowPlaySounds()
- togglePauseSound(sound)
- updatePlaylistPreferences()
Member Index
- allowed_instructional_formats
- allowed_waveform_formats
- app
- background_music
- background_paused
- background_playlist
- entities_waiting_for_sound_to_be_enabled
- has_bg_music
- load_music
- midi_player
- not_loaded
- old_bg_music_volume
- played_sound_callbacks
- sound_archive
- sound_fx
- speech_file_name
- unused_played_callback_id
- warned
function Audio:Audio(app)
Parameters:
| Name | Type | Description |
|---|---|---|
| app | ? | ? |
Declared on: line 35 of Lua/audio.lua.
function Audio:cacheSoundFilenamesAssociatedWithName(name)
Parameters:
| Name | Type | Description |
|---|---|---|
| name | ? | ? |
Declared on: line 403 of Lua/audio.lua.
function Audio:clearCallbacks()
Declared on: line 55 of Lua/audio.lua.
function Audio:destroy()
Declared on: line 849 of Lua/audio.lua.
function Audio:dumpSoundArchive(out_dir)
Parameters:
| Name | Type | Description |
|---|---|---|
| out_dir | ? | ? |
Declared on: line 292 of Lua/audio.lua.
function Audio:entityNoLongerWaitingForSoundsToBeTurnedOn(entity)
Parameters:
| Name | Type | Description |
|---|---|---|
| entity | ? | ? |
Declared on: line 819 of Lua/audio.lua.
function Audio:entitySoundsHandler(sounds, entity, silences, silences_pointer)
Called by the above function.
This function's integer array parameters for the min and max silence lengths should provide lengths
for this game's different speeds, indexed as follows:
[1] Slowest [2] Slow [3] Normal [4] Fast [5] Maximum Speed
Parameters:
| Name | Type | Description |
|---|---|---|
| sounds | string | A name pattern for the sequence of related sounds to be played for example: LAVA00*.wav |
| entity | ? | : Where the sounds will be played at, the player won't hear the sounds being played at the entity when it isn't in their view. |
| silences | integer or array | the different pause durations to be used between the played sounds. |
| silences_pointer | integer | the index for the pause duration which should be used after this call's sound has been played. -- |
Declared on: line 482 of Lua/audio.lua.
function Audio:getFileData(index)
Parameters:
| Name | Type | Description |
|---|---|---|
| index | ? | ? |
Declared on: line 681 of Lua/audio.lua.
function Audio:getMidiApiList()
Declared on: line 215 of Lua/audio.lua.
function Audio:getMidiPortList()
Declared on: line 219 of Lua/audio.lua.
function Audio:init()
Declared on: line 71 of Lua/audio.lua.
function Audio:initMidiPlayer()
Declared on: line 196 of Lua/audio.lua.
function Audio:initSpeech(speech_file)
Parameters:
| Name | Type | Description |
|---|---|---|
| speech_file | ? | ? |
Declared on: line 227 of Lua/audio.lua.
function Audio:isPlaying(sound)
Determine if a given sound is still playing
Parameters:
| Name | Type | Description |
|---|---|---|
| sound | table | The `sound` table returned by `Audio:playSound`. |
Declared on: line 389 of Lua/audio.lua.
function Audio:notifyJukebox()
search for jukebox and notify it to update its play button
Declared on: line 827 of Lua/audio.lua.
function Audio:onEndPause()
Declared on: line 527 of Lua/audio.lua.
function Audio:onMusicOver()
Declared on: line 769 of Lua/audio.lua.
function Audio:onSoundPlayed(played_callbacks_id)
Parameters:
| Name | Type | Description |
|---|---|---|
| played_callbacks_id | ? | ? |
Declared on: line 533 of Lua/audio.lua.
function Audio:pauseBackgroundTrack()
Returns whether music is currently paused or not after the call.
If nil is returned music might either be playing or completely stopped.
Declared on: line 615 of Lua/audio.lua.
function Audio:playBackgroundTrack(index)
Plays a given background track.
Playback will only start if the configuration says it's ok. (play_music = true)
Parameters:
| Name | Type | Description |
|---|---|---|
| index | ? | Index of the track to play in the playlist. |
Declared on: line 696 of Lua/audio.lua.
function Audio:playEntitySounds(names, entity, min_silence_lengths, max_silence_lengths, num_silences)
Plays related sounds at an entity in a random sequence, with random length silences between the sounds.
This function's integer array parameters for the min and max silence lengths should provide lengths
for this game's different speeds, indexed as follows:
[1] Slowest [2] Slow [3] Normal [4] Fast [5] Maximum Speed
Parameters:
| Name | Type | Description |
|---|---|---|
| names | string | A name pattern for the sequence of related sounds to be played for example: LAVA00*.wav |
| entity | ? | : Where the sounds will be played at, the player won't hear the sounds being played at the entity when it isn't in their view. |
| min_silence_lengths | integer or array | The desired minimum silence lengths for this game's different speeds. |
| max_silence_lengths | integer or array | The desired maximum silence lengths for this game's different speeds. |
| num_silences | integer | How many different silence lengths should be used, this can be a nil parameter. -- |
Declared on: line 456 of Lua/audio.lua.
function Audio:playNextOrPreviousBackgroundTrack(direction)
Parameters:
| Name | Type | Description |
|---|---|---|
| direction | ? | ? |
Declared on: line 581 of Lua/audio.lua.
function Audio:playSound(name, where, is_announcement, played_callback, played_callback_delay, loops)
Play a sound from the sound archive
Parameters:
| Name | Type | Description |
|---|---|---|
| name | string | The name of the sound to be played. Can include wildcards (*). |
| where | Entity | The entity that is the source of the sound, or nil if the audio is not positional. |
| is_announcement | boolean | Whether the sound is an announcement (affects volume). |
| played_callback | function | A function to be called when the sound has finished playing. Can be nil. |
| played_callback_delay | integer | An optional delay in milliseconds before the played_callback is called. |
| loops | integer | number of times to play the audio. -1 for infinite. |
Declared on: line 316 of Lua/audio.lua.
function Audio:playSoundEffects(play_effects)
Parameters:
| Name | Type | Description |
|---|---|---|
| play_effects | ? | ? |
Declared on: line 798 of Lua/audio.lua.
function Audio:readPlaylistPreferences()
Load the playlist disabled tracks file
Declared on: line 857 of Lua/audio.lua.
function Audio:releaseChannel(channel)
Parameters:
| Name | Type | Description |
|---|---|---|
| channel | ? | ? |
Declared on: line 843 of Lua/audio.lua.
function Audio:reserveChannel()
Declared on: line 835 of Lua/audio.lua.
function Audio:resolveFilenameWildcard(name)
Resolves sound filename containing wildcard character from its associated variants
Parameters:
| Name | Type | Description |
|---|---|---|
| name | string | Filename containing wildcard character to resolve |
Declared on: line 420 of Lua/audio.lua.
function Audio:setAnnouncementVolume(volume)
Parameters:
| Name | Type | Description |
|---|---|---|
| volume | ? | ? |
Declared on: line 823 of Lua/audio.lua.
function Audio:setBackgroundVolume(volume)
Parameters:
| Name | Type | Description |
|---|---|---|
| volume | ? | ? |
Declared on: line 776 of Lua/audio.lua.
function Audio:setSoundStage()
Set the visual area for sound effects playback
Declared on: line 283 of Lua/audio.lua.
function Audio:setSoundVolume(volume)
Parameters:
| Name | Type | Description |
|---|---|---|
| volume | ? | ? |
Declared on: line 789 of Lua/audio.lua.
function Audio:soundExists(sound)
Returns whether the given sound (either a string or a number)
exists in the sound archive
Parameters:
| Name | Type | Description |
|---|---|---|
| sound | ? | The sound to look for, either a string (name) or a number (position in the list of sounds) |
Declared on: line 542 of Lua/audio.lua.
function Audio:stopBackgroundTrack()
Stops playing background music for the time being.
Does not affect the configuration setting play_music.
Declared on: line 665 of Lua/audio.lua.
function Audio:stopSound(sound)
Stop a playing sound.
A stopped sound is destroyed and cannot be resumed. The callback will be not
be called for the stopped sound.
Parameters:
| Name | Type | Description |
|---|---|---|
| sound | table | The `sound` table returned by `Audio:playSound`. |
Declared on: line 374 of Lua/audio.lua.
function Audio:togglePauseSound(sound)
Pause or unpause a playing sound
Parameters:
| Name | Type | Description |
|---|---|---|
| sound | table | The `sound` table returned by `Audio:playSound`. |
Declared on: line 361 of Lua/audio.lua.
function Audio:updatePlaylistPreferences()
Create a set of playlist filenames that are disabled and write this to file
Declared on: line 870 of Lua/audio.lua.