atmoky Engage Server SDK is now available! Check out the documentation to learn more.
API Reference
Classes
Space

Space

Summary
The Space class is the main entry point for the SDK. It holds audio objects, rooms, and the audio listener.
Remarks
This class manages both the communication part of the SDK as well as the spatial audio part. The client can use it to join room, in which participants can join and communicate with each other. Also AudioObjects for static or interactive sounds within the space can be created. The Space class also holds the AudioListener, which can be used to set the virtual listener's position and orientation. Additionally, it provides controls for reverb, the externalizer, and the DistanceModels which define how the volume of an AudioObject changes over distance.
When the space is created it sets up the spatial audio rendering. This is an ansynchronous task. The spatialAudioInitializedPromise member can be used to wait for the spatial audio rendering to be ready. In addition, the spatialAudioInitialized member shows if the spatial audio rendering has been initialized.
Most browsers require user interaction to start the audio context. Therefore, the space's resumeAudio method should be called after the user has interacted with the application.

Constructor

Creates a new Space instance.
Signature
new Space(options?: SpaceOptions)
NameTypeDescription
options optionalSpaceOptionsOptions for the space.

Properties

audioBed

optional
Instance of the audio bed.
Remarks
Can be used to play back content that should stay static with regard to the listener.

audioListener

Instance of the virtual audio listener.
Remarks
Can be used to set the virtual listener's position and orientation.

audioObjects

List of audio objects in the space.

rooms

List of communication rooms in the space.
Type
Room[]

spatialAudioInitialized

Indicates if spatial audio has been initialized
Type
boolean

spatialAudioInitializedPromise

Promise that resolves when spatial audio has been initialized
Remarks
Additionally to this promise resolving, SpaceEvent.AudioInitialized is also emitted.
Type
Promise<void>

Accessors

distanceModels

Returns the list of available distance models.
Remarks
DistanceModels describe how the gain changes with distance. The number of distance models can be defined in the SpaceOptions when creating a space.

Methods

createAudioObject

Creates a new audio object and adds it to the space.
Signature
createAudioObject()
Returns
AudioObject The newly created audio object.

getAudioContext

Returns the space's audio context.
Signature
getAudioContext()
Returns
AudioContext

getNumberOfAutoConnections

Returns the currently set number of allowed auto connections.
Signature
getNumberOfAutoConnections()
Returns
number the number of allowed auto connections

getNumberOfObjectsAvailable

Returns the number of audio objects available for use.
Signature
getNumberOfObjectsAvailable()
Returns
number The number of audio objects available for use.

getNumberOfObjectsInUse

Returns the number of audio objects currently in use.
Signature
getNumberOfObjectsInUse()
Returns
number the number of audio objects currently in use.

joinRoom

Joins a room.
Signature
joinRoom(url: string, token: string, roomOptions?: RoomOptions)
NameTypeDescription
urlstringRTC server URL
tokenstringAccess token for the room
roomOptions optionalRoomOptionsOptions for the room
Returns
Room the room instance the user attempts to join

leaveAllRooms

Leaves all rooms.
Signature
leaveAllRooms()
Returns
void

leaveRoom

Leaves the provided room.
Signature
leaveRoom(room: Room)
NameTypeDescription
roomRoomThe room to leave
Returns
Promise<void>

removeAllAudioObjects

Removes all audio objects from the space.
Signature
removeAllAudioObjects()
Returns
void

removeAudioObject

Removes an audio object from the space.
Signature
removeAudioObject(audioObject: AudioObject)
NameTypeDescription
audioObjectAudioObjectThe audio object to remove.
Returns
void

resumeAudio

Resumes the audio context.
Signature
resumeAudio()
Returns
Promise<void> A promise that resolves when the audio context has been resumed.
Remarks
Most browsers require user interaction to start the audio context.

setExternalizerAmount

Sets the externalizer amount (0 - 100).
Signature
setExternalizerAmount(amount: number)
NameTypeDescription
amountnumber
Returns
void

setExternalizerCharacter

Sets the externalizer character (0 - 100).
Signature
setExternalizerCharacter(character: number)
NameTypeDescription
characternumber
Returns
void

setNumberOfAutoConnections

Sets the number of allowed auto connections.
Signature
setNumberOfAutoConnections(numAutoConnections: number)
NameTypeDescription
numAutoConnectionsnumbernumber of auto connections
Returns
void

setReverbAmount

Sets the reverb amount (0 - 100).
Signature
setReverbAmount(amount: number)
NameTypeDescription
amountnumber
Returns
void

suspendAudio

Suspends the audio context.
Signature
suspendAudio()
Returns
Promise<void> A promise that resolves when the audio context has been suspended.

atmoky Logo

© 2024 atmoky, GmbH.
All rights reserved.

We use cookies to measure and improve your browsing experience, and serve personalized ads or content.