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

Space

A Space is the main entry point of the Engage Client SDK. Your client application usually has a single Space instance which is the container for AudioObjects, Rooms and their Participants, and also the Spatial Audio Rendering Engine.
Space Options
Using the SpaceOptions you can configure the Space to your needs. For example providing a custom AudioContext, or setting the number of AudioObjects and DistanceModels. You can also set the Coordinate System to be used for the Space. See SpaceOptions for more details.
Spatial Audio Rendering Engine
Upon creation it will start setting up the audio graph in the background. You can use the Space.spatialAudioInitialized promise to wait for the audio graph to be ready before adding audio objects.

Basic Usage

Create a Space

import { Space } from "@atmokyaudio/engage-client";
 
const space = new Space({
    audioContext: new AudioContext(),
    numberOfAudioObjects: 10,
    numberOfDistanceModels: 10,
});

Setup Event Listeners

The Space emits SpaceEvents and also forwards events from Rooms and Participants. You can listen for these events by calling space.on() and passing in the event name and a callback function.
space.on("someEvent", () => {
    // do something
});
You can use space.off("someEvent", callback) to remove event listeners again.

Resume the AudioContext

The AudioContext needs to be resumed before it can be used. You can do this by calling space.resume(). As most browsers require a user interaction to resume the AudioContext, you should call this method in response to a user interaction.
button.addEventListener("click", () => {
    space.resumeAudio();
});

Going further

Read on for how to create AudioObjects, join Rooms, and set rendering parameters.

atmoky Logo

© 2024 atmoky, GmbH.
All rights reserved.

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