Module: sfx

Sound effects API. Uses Web Audio API for sound effects and HTML5 audio for background music.

Summary

Methods

Detailed Description

Methods

apply_playlist(objs, delay, random)

Apply the new playlist from the given set of speakers. The new playlist starts playing immediately.
Parameters:
Name Type Description
objs Array.<Object3D> Array of objects.
delay Number Number of seconds between tracks
random Boolean Randomize playback sequence
Source:

check_active_speakers() → {Boolean}

Check if there are some active speakers in use or not.
Returns:
Check result
Type
Boolean
Source:

clear_playlist()

Stop playback and clear the playlist.
Source:

cyclic(obj, cyclic)

Set cyclic flag.
Parameters:
Name Type Description
obj Object3D Speaker object.
cyclic Boolean New cyclic flag value.
Source:

detect_audio_container(hintopt) → {String}

Detect supported audio containter. Containers have same meaning as file extension here, for each one possible fallback exists:
  • ogg -> mp4
  • mp3 -> ogg
  • mp4 -> ogg
Parameters:
Name Type Attributes Default Description
hint String <optional>
"ogg" Required container
Returns:
Supported containter or ""
Type
String
Source:

detect_video_container(hintopt) → {String}

Detect supported video containter. Containers have same meaning as file extension here, for each one possible fallback exists:
  • ogv -> m4v
  • m4v -> webm
  • webm -> m4v
Parameters:
Name Type Attributes Default Description
hint String <optional>
"webm" Required container
Returns:
Supported containter or ""
Type
String
Source:

duck(objnullable, value, time)

Duck (reduce the volume). works independently from the volume API and the volume randomization
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D or null for MASTER
value Number Duck amount.
time Number Time to change volume.
Source:

get_compressor_params() → {CompressorParams}

Get compressor params.
Returns:
Params object
Type
CompressorParams
Source:

get_filter_freq_response(obj, freq_arr, mag_arr, phase_arr)

Get filter frequency response.
Parameters:
Name Type Description
obj Object3D Object 3D
freq_arr Float32Array Input array with frequencies.
mag_arr Float32Array Ouput array with filter response magnitudes.
phase_arr Float32Array Output array with filter response phases.
Source:

get_filter_params(obj) → {FilterParams}

Get filter params.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Params object
Type
FilterParams
Source:

get_positional_params(obj) → {PositionalParams}

Get positional params.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Params object
Type
PositionalParams
Source:

get_speaker_objects() → {Array}

Get the speaker objects which are used by the module.
Returns:
Speaker object array
Type
Array
Source:

get_volume(objnullable) → {Number}

Get volume level.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D or null for MASTER volume
Returns:
Volume (0..1)
Type
Number
Source:

get_volume(objnullable) → {Number}

Get duration of the speaker's playback cycle. Zero duration means looped or non-ready speaker
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Speaker object.
Returns:
Duration
Type
Number
Source:

is_cyclic(obj) → {Boolean}

Check if the cyclic flag is set.
Parameters:
Name Type Description
obj Object3D Speaker object.
Returns:
Cyclic flag value.
Type
Boolean
Source:

is_muted(objnullable) → {Boolean}

Check if the speaker is muted.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Speaker object or null for all of them.
Returns:
Muted state.
Type
Boolean
Source:

is_play(obj) → {Boolean}

Check if sound is played through the speaker now.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Playing state
Type
Boolean
Deprecated:
Source:

is_playing(obj) → {Boolean}

Check if sound is played through the speaker now.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Playing state
Type
Boolean
Source:

listener_reset_speed(speed, diropt, nullable)

Reset the listener speed. Use before rapid listener movements to neutralize undesirable doppler effect.
Parameters:
Name Type Attributes Default Description
speed Number The listener new speed
dir Float32Array <optional>
<nullable>
null The listener new direction
Deprecated:
Source:

listener_stride()

Make a listener stride. Use before quick listener movements to neutralize undesirable doppler effect.
Source:

loop_stop(obj, whenopt, waitopt)

Stop the speaker's looping playback.
Parameters:
Name Type Attributes Default Description
obj Object3D Speaker object
when Number <optional>
0 Delay after exec in seconds
wait Boolean <optional>
false Wait loop until currently played cycle is finished
Source:

mute(objnullable, muted)

Mute/unmute.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Speaker object or null for all of them
muted Boolean New state
Source:

pause(obj)

Pause the speaker.
Parameters:
Name Type Description
obj Object3D Object 3D
Source:

play(obj, whenopt, durationopt)

Play sound through the speaker.
Parameters:
Name Type Attributes Default Description
obj Object3D Object 3D
when Number <optional>
0 Delay after exec in seconds
duration Number <optional>
0 Duration of the speaker's playback cycle (in seconds). duration=0 - assign default value according to sound playback length.
Source:

play_def(obj)

Play sound through the speaker using the default delay and duration params.
Parameters:
Name Type Description
obj Object3D Object 3D
Source:

playrate(obj) → {Number}

Get the speaker playback rate value.
Parameters:
Name Type Description
obj Object3D Object 3D
Returns:
Playback rate
Type
Number
Source:

playrate(obj, playrate)

Change the speaker playback rate value.
Parameters:
Name Type Description
obj Object3D Object 3D
playrate Number Playback rate (1.0 - normal speed).
Source:

resume(obj)

Resume the paused speaker.
Parameters:
Name Type Description
obj Object3D Object 3D
Source:

set_compressor_params(params)

Set compressor params.
Parameters:
Name Type Description
params CompressorParams Params object
Source:

set_filter_params(obj, params)

Set filter params.
Parameters:
Name Type Description
obj Object3D Object 3D
params FilterParams Params object
Source:

set_positional_params(obj, params)

Set positional params.
Parameters:
Name Type Description
obj Object3D Object 3D
params PositionalParams Params object
Source:

set_volume(objnullable, volume)

Set volume level.
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D or null for MASTER volume
volume Number Volume (0..1)
Source:

speaker_reset_speed(obj)

Make a speaker stride. Use before rapid speaker movements to neutralize undesirable doppler effect.
Parameters:
Name Type Description
obj Object3D Speaker object.
Source:

speaker_reset_speed(obj, speed, diropt, nullable)

Reset the speaker speed. It's necessary to nullify speed before the speaker has moved quickly in order to neutralize the undesirable doppler effect.
Parameters:
Name Type Attributes Default Description
obj Object3D Speaker object.
speed Number The speaker's new speed
dir Float32Array <optional>
<nullable>
null The speaker's new direction
Deprecated:
  • Use sfx.speaker_stride instead
Source:

stop(obj)

Stop the speaker.
Parameters:
Name Type Description
obj Object3D Object 3D
Source:

unduck(objnullable)

Unduck (restore the volume).
Parameters:
Name Type Attributes Description
obj Object3D <nullable>
Object 3D or null for MASTER
Source: