Using Audio Capabilities

The following examples demonstrate how to use the audio capabilities of the most recent version of the Dolby.io Communications SDK for Web.

Join a conference with audio off

// Create a new conference or get the conference object from the ID
const conference = await VoxeetSDK.conference.fetch('conferenceId');

const constraints = {
    audio: false, // No audio on join
    video: true,
};

await VoxeetSDK.conference.join(conference, { constraints: constraints });

Join a conference with audio on

// Create a new conference or get the conference object from the ID
const conference = await VoxeetSDK.conference.fetch('conferenceId');

const constraints = {
    audio: true,
    video: true,
};

await VoxeetSDK.conference.join(conference, { constraints: constraints });

Specify the audio bitrate when joining a conference

You can set the audio bitrate when joining a non-Dolby Voice conference.

// Create a non-Dolby Voice conference
const conference = await VoxeetSDK.conference.create({
    alias: 'my conference',
    params: {
        dolbyVoice: false,
    },
});

const constraints = {
    audio: true,
    video: true,
    audioBitrate: '64kbps', // See: https://docs.dolby.io/communications-apis/docs/js-client-sdk-model-audiobitrate
};

await VoxeetSDK.conference.join(conference, { constraints: constraints });

Turn on the local audio

await VoxeetSDK.audio.local.start();

If your video is on, the following event will also be triggered:

VoxeetSDK.conference.on("streamUpdated", (participant, stream) => {
    
});

If your video is off, the following event will also be triggered:

VoxeetSDK.conference.on("streamAdded", (participant, stream) => {
    
});

Turn off the local audio

await VoxeetSDK.audio.local.stop();

Mute the local audio

The difference between stopAudio() and mute() is that the mute() will keep the audio stream running while the stopAudio() will stop the stream and a startAudio() will require a renegotiation between the client and the server, so it will take a few milliseconds before being able to share the audio into the conference. Also, the stopAudio() releases the microphone while the mute() does not.

VoxeetSDK.conference.mute(VoxeetSDK.session.participant, true);

Unmute the local audio

VoxeetSDK.conference.mute(VoxeetSDK.session.participant, false);

Stop receiving the audio from a remote user

const remoteParticipant = VoxeetSDK.conference.participants.get('PARTICIPANT_ID');

await VoxeetSDK.audio.remote.stop(remoteParticipant);

Start receiving the audio from a remote user

const remoteParticipant = VoxeetSDK.conference.participants.get('PARTICIPANT_ID');

await VoxeetSDK.audio.remote.start(remoteParticipant);

Change the comfort noise level

Changing the comfort noise level is only available in Dolby Voice conferences for users using the Dolby Voice codec.

// Set the comfort noise level to medium
await VoxeetSDK.audio.local.setComfortNoiseLevel('medium');

const level = await VoxeetSDK.audio.local.getComfortNoiseLevel();
console.log(`Comfort noise level set to: ${level}`);

Change the audio constraints

Calling this method by listeners or participants who use the Dolby Voice Codec (dvwc flag set to true) triggers the UnsupportedError.

const audioConstraints = {
    echoCancellation: false,
    noiseSuppression: false,
};

await VoxeetSDK.audio.local.applyConstraints(audioConstraints);

Change the capture mode

Standard mode

This is the default capture mode. Optimizes captured audio for speech by aggressively removing non-speech content, such as background noise. This mode additionally enhances speech perceptibility to create a conversation-focused conference environment.

Turn on standard mode capture

await VoxeetSDK.audio.local.setCaptureMode({ mode: 'standard' });

Change the noise reduction level

In standard mode, you can change the noise reduction level.

const captureMode = {
    mode: 'standard',
    modeOptions: {
        noiseReductionLevel: 'low', // See: https://docs.dolby.io/communications-apis/docs/js-client-sdk-model-audiocapturemodestandardoptions
    },
};

await VoxeetSDK.audio.local.setCaptureMode(captureMode);

Use voice fonts

In standard mode, you can also use voice fonts.

const captureMode = {
    mode: 'standard',
    modeOptions: {
        noiseReductionLevel: 'high',
        voiceFont: 'DarkModulation',
    },
};
await VoxeetSDK.audio.local.setCaptureMode(captureMode);

Change audio output volume

Set the volume of all remote participants

VoxeetSDK.audio.remote.setOutputVolume(0.3);

Set the volume of a selected remote participant

This functionality is supported only in non-Dolby Voice conferences.

VoxeetSDK.audio.remote.setVolume(remoteParticipantA, 0.5);

Music mode

Allows transmitting a high-quality audio stream with audio enhancements designed to improve the perceptual quality of music content. This mode is perfect for music lessons, virtual concerts, and music-focused webinars. For additional information, see Music Mode.

Music mode is only available on Chromium browsers (Chrome and Edge).

Turn on music mode capture

await VoxeetSDK.audio.local.setCaptureMode({ mode: 'music' });

Turn off music mode capture

To turn off the music mode, revert to Standard or Unprocessed mode.

await VoxeetSDK.audio.local.setCaptureMode({ mode: 'standard' });

Turn off echo cancellation

const captureMode = {
    mode: 'music',
    modeOptions: {
        echoCancellation: 'off',
    },
};

await VoxeetSDK.audio.local.setCaptureMode(captureMode);

Turn on echo cancellation

const captureMode = {
    mode: 'music',
    modeOptions: {
        echoCancellation: 'on',
    },
};

await VoxeetSDK.audio.local.setCaptureMode(captureMode);

Unprocessed mode

Disables audio processing to allow transmitting non-voice audio to a conference.

await VoxeetSDK.audio.local.setCaptureMode({ mode: 'unprocessed' });