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

Audio Bed

In contrast to to audio objects which have a position in space, sounds can also be played back using an audio bed, which the listener will carry while moving. The AudioBed supports playback of multi-channel audio files in a variety of formats like stereo, surround formats, or even Ambisonics. The individual channels / the soundfield will be automatically spatialized around the listener. It's the perfect fit for background music & ambience, or a narrator voice. The Audio Bed can be made headlocked, so it will not just move but also rotate with the listener. This can be useful if you want a narrator voice to always come from the same direction.

Basic Usage

Create a Space with an AudioBed

Setup of the AudioBed is handled by the Space. You just need to specify the format when the Space is created via AudioBedFormat.
import { AudioFile, AudioBedFormat, Space } from "@atmokyaudio/engage-client";
 
const space = new Space({
    audioContext: new AudioContext(),
    numberOfAudioObjects: 10,
    numberOfDistanceModels: 10,
    audioBedFormat: AudioBedFormat.Stereo,
});

Set a source for the AudioBed

// trigger connecting the input once spatial audio is done with init
space.spatialAudioInitializedPromise.then(() => {
    const audioBed = space.audioBed!;
    const audioFile = new AudioFile(space.getAudioContext());
 
    audioFile
        .load("https://some-audio-file.mp3")
        .then(() => console.log("Audio file loaded"));
 
    audioFile.setLoop(true);
    audioBed.setInput(audioFile);
});
You can assign an arbitrary number of inputs to an AudioBed.
⚠️
Make sure that you do not try to interact with the AudioBed before space.spatialAudioInitialized === true, or the AudioBed will be undefined.

Modifying rendering properties

audioBed.setHeadlocked(true);
audioBed.setGainLinear(0.5);
audioBed.setGainDecibels(-9.0);

atmoky Logo

© 2024 atmoky, GmbH.
All rights reserved.

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