openspace.audio
Functions overview
Name |
Documentation |
---|---|
Returns the list of all tracks that are currently playing |
|
Returns the global volume for all track |
|
Returns whether the track referred to by the \p identifier is set to be looping or whether it should played only once |
|
Returns whether the track refered to by the \p identifier is currently playing or paused |
|
Returns whether the track referred to by the \p identifier is currently playing |
|
Pauses the playback for all sounds, while keeping them valid |
|
Pauses the playback of the track referred to by the \p identifier |
|
Takes all of the sounds that are currently registers, unpauses them and plays them from their starting points |
|
Starts playing the audio file located and the provided \p path |
|
Starts playing the audio file located and the provided \p path |
|
Resumes the playback for all sounds that have been paused |
|
Resumes the playback of a track that was previously paused through the #pauseAudio function |
|
Sets the position and orientation of the listener |
|
Updates the 3D position of a track started through the #playAudio3d function |
|
Sets the global volume for all track referred to the new \p volume |
|
Controls whether the track referred to by the \p identifier should be looping or just be played once |
|
Sets the position of the speaker for the provided \p channel to the provided \p position |
|
Sets the volume of the track referred to by \p handle to the new \p volume |
|
Returns the position for the speaker of the provided \p channel |
|
Stops all currently playing tracks |
|
Stops the audio referenced by the \p identifier |
|
Returns the volume for the track referred to by the \p handle |
Functions
currentlyPlaying
Returns the list of all tracks that are currently playing.
Return type: String[]
openspace.audio.currentlyPlaying()
globalVolume
Returns the global volume for all track. The number returned will be greater or equal to 0.
Return type: Number
openspace.audio.globalVolume()
isLooping
Returns whether the track referred to by the \p identifier is set to be looping or whether it should played only once. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
Return type: Boolean
Yes
if the track is looping, No
otherwise
openspace.audio.isLooping(identifier)
isPaused
Returns whether the track refered to by the \p identifier is currently playing or paused. If it was be paused through a previous call to #pauseAudio, this function will return true
. If it has just been created or resumed through a call to #resumeAudio, it will return false
. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
Return type: Boolean
true
if the track is currently paused, false
if it is playing
openspace.audio.isPaused(identifier)
isPlaying
Returns whether the track referred to by the \p identifier is currently playing. A volume of 0 is still considered to be playing. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
Return type: Boolean
true
if the track is currently playing, false
otherwise
openspace.audio.isPlaying(identifier)
pauseAll
Pauses the playback for all sounds, while keeping them valid. This function behaves the same as if calling #pauseAudio on all of the sounds that are currently playing.
Return type: void
openspace.audio.pauseAll()
pauseAudio
Pauses the playback of the track referred to by the \p identifier. The playback can later be resumed through the #resumeAudio function. Trying to pause an already paused track will not do anything, but is valid. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
Return type: void
openspace.audio.pauseAudio(identifier)
playAllFromStart
Takes all of the sounds that are currently registers, unpauses them and plays them from their starting points
Return type: void
openspace.audio.playAllFromStart()
playAudio
Starts playing the audio file located and the provided \p path. The \p loop parameter determines whether the file is only played once, or on a loop. The sound is later referred to by the \p identifier name. The audio file will be played in “background” mode, which means that each channel will be played at full volume. To play a video using spatial audio, use the #playAudio3d function instead.
path
Path
The audio file that should be played
identifier
String
The name for the sound that is used to refer to the sound
shouldLoop
Boolean?
- Default value:true
Return type: void
openspace.audio.playAudio(path, identifier, shouldLoop)
playAudio3d
Starts playing the audio file located and the provided \p path. The \p loop parameter determines whether the file is only played once, or on a loop. The sound is later referred to by the \p identifier name. The \p position parameter determines the spatial location of the sound in a meter-based coordinate system. The position of the listener is (0,0,0) with the forward direction along the +y axis. This means that the “left” channel in a stereo setting is towards -x and the “right” channel towards x. This default value can be customized through the #set3dListenerParameters function. If you want to play a video without spatial audio, use the #playAudio function instead.
path
Path
The audio file that should be played
identifier
String
The name for the sound that is used to refer to the sound
position
vec3
The position of the audio file in the 3D environment
shouldLoop
Boolean?
- Default value:true
Return type: void
openspace.audio.playAudio3d(path, identifier, position, shouldLoop)
resumeAll
Resumes the playback for all sounds that have been paused. Please note that this will also resume the playback for the sounds that have been manually paused, not just those that were paused through the #pauseAll function.
Return type: void
openspace.audio.resumeAll()
resumeAudio
Resumes the playback of a track that was previously paused through the #pauseAudio function. Trying to resume an already playing track will not do anything, but is valid. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
Return type: void
openspace.audio.resumeAudio(identifier)
set3dListenerPosition
Sets the position and orientation of the listener. This new position is automatically used to adjust the relative position of all 3D tracks. Each parameter to this function call is optional and if a value is omitted, the currently set value continues to be used instead. The coordinate system for the tracks and the listener is a meter-based coordinate system.
position
vec3
The position of the listener.
lookAt
vec3?
The direction vector of the forward direction
up
vec3?
The up-vector of the coordinate system
Return type: void
openspace.audio.set3dListenerPosition(position, lookAt, up)
set3dSourcePosition
Updates the 3D position of a track started through the #playAudio3d function. See that function and the #set3dListenerParameters function for a complete description. The \p identifier must be a name for a sound that was started through the #playAudio3d function.
identifier
String
position
vec3
The new position from which the track originates
Return type: void
openspace.audio.set3dSourcePosition(identifier, position)
setGlobalVolume
Sets the global volume for all track referred to the new \p volume. The total for each track is the global volume set by this function multiplied with the volume for the specific track set through the #setVolume function. The default value for the global volume is 0.5. The volume should be a number bigger than 0, where 1 is the maximum volume level. The \p fade controls whether the volume change should be immediately (if it is 0) or over how many seconds it should change. The default is for it to change over 500 ms.
volume
Number
The new volume level. Must be greater or equal to 0
fade
Number?
- Default value:0.5f
How much time the fade from the current volume to the new volume should take
Return type: void
openspace.audio.setGlobalVolume(volume, fade)
setLooping
Controls whether the track referred to by the \p identifier should be looping or just be played once. If a track is converted to not looping, it will finish playing until the end of the file. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions.
identifier
String
The identifier to the track that should be stopped
shouldLoop
Boolean
Return type: void
openspace.audio.setLooping(identifier, shouldLoop)
setSpeakerPosition
Sets the position of the speaker for the provided \p channel to the provided \p position. In general, this is considered an advanced feature to accommodate non-standard audio environments.
handle
Integer
position
vec3
The new position for the speaker
Return type: void
openspace.audio.setSpeakerPosition(handle, position)
setVolume
Sets the volume of the track referred to by \p handle to the new \p volume. The volume should be a number bigger than 0, where 1 is the maximum volume level. The \p fade controls whether the volume change should be immediately (if it is 0) or over how many seconds it should change. The default is for it to change over 500 ms.
identifier
String
volume
Number
The new volume level. Must be greater or equal to 0
fade
Number?
- Default value:0.5f
How much time the fade from the current volume to the new volume should take
Return type: void
openspace.audio.setVolume(identifier, volume, fade)
speakerPosition
Returns the position for the speaker of the provided \p channel.
handle
Integer
Return type: vec3
openspace.audio.speakerPosition(handle)
stopAll
Stops all currently playing tracks. After this function, none of the identifiers used to previously play a sound a valid any longer, but can still be used by the #playAudio or #playAudio3d functions to start a new sound. This function behaves the same way as if manually calling #stopAudio on all of the sounds that have been started.
Return type: void
openspace.audio.stopAll()
stopAudio
Stops the audio referenced by the \p identifier. The \p identifier must be a name for a sound that was started through the #playAudio or #playAudio3d functions. After this function, the \p identifier can not be used for any other function anymore except for #playAudio or #playAudio3d to start a new sound.
identifier
String
The identifier to the track that should be stopped
Return type: void
openspace.audio.stopAudio(identifier)
volume
Returns the volume for the track referred to by the \p handle. The number returned will be greater or equal to 0.
identifier
String
Return type: Number
openspace.audio.volume(identifier)