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)
Name | Type | Description |
---|---|---|
options optional | SpaceOptions | Options for the space. |
Properties
audioBed
optional
Instance of the audio bed.
Instance of the audio bed.
Remarks
Can be used to play back content that should stay static with regard to the listener.Type
AudioBed
audioListener
Instance of the virtual audio listener.
Remarks
Can be used to set the virtual listener's position and orientation.Type
AudioListener
audioObjects
List of audio objects in the space.
Type
AudioObject[]
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.
Type
DistanceModel[]
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 connectionsgetNumberOfObjectsAvailable
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)
Name | Type | Description |
---|---|---|
url | string | RTC server URL |
token | string | Access token for the room |
roomOptions optional | RoomOptions | Options for the room |
Returns
Room
the room instance the user attempts to joinleaveAllRooms
Leaves all rooms.
Signature
leaveAllRooms()
Returns
void
leaveRoom
Leaves the provided room.
Signature
leaveRoom(room: Room)
Name | Type | Description |
---|---|---|
room | Room | The 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)
Name | Type | Description |
---|---|---|
audioObject | AudioObject | The 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)
Name | Type | Description |
---|---|---|
amount | number |
Returns
void
setExternalizerCharacter
Sets the externalizer character (0 - 100).
Signature
setExternalizerCharacter(character: number)
Name | Type | Description |
---|---|---|
character | number |
Returns
void
setNumberOfAutoConnections
Sets the number of allowed auto connections.
Signature
setNumberOfAutoConnections(numAutoConnections: number)
Name | Type | Description |
---|---|---|
numAutoConnections | number | number of auto connections |
Returns
void
setReverbAmount
Sets the reverb amount (0 - 100).
Signature
setReverbAmount(amount: number)
Name | Type | Description |
---|---|---|
amount | number |
Returns
void
suspendAudio
Suspends the audio context.
Signature
suspendAudio()
Returns
Promise
<void
> A promise that resolves when the audio context has been suspended.