Music Mode

Use music mode to enable high quality audio streaming. This is useful when you have a use-case of streaming music that's getting captured through the mic.

Minimum Requirements

The following are the minimum version requirements:

  • hms-video-store - 0.12.14
  • react-sdk - 0.10.14

What is Music Mode?

Music Mode is a feature that allows you to capture audio in its highest quality by disabling voice processing and increasing the maximum bandwidth limit. By default, audio is processed to enhance human voice clarity, which includes techniques like noise cancellation and automatic gain control. However, this processing can suppress background music and lower its quality.

With Music Mode, you can remove these voice processing methods and capture all types of frequencies with your microphone, making it ideal for recording music or any other audio that isn't focused solely on voice. Additionally, the maximum bandwidth limit for audio is increased from 32 Kbps to 320 Kbps. This higher limit ensures that music is not compressed too much and is captured in its original quality.

How to turn on Music Mode?

Music mode can be enabled with the following snippet:

Using the vanilla JavaScript SDK:

import { HMSAudioMode, HMSReactiveStore } from '@100mslive/hms-video-store'; const hmsManager = new HMSReactiveStore(); const hmsActions = hmsManager.getActions(); await hmsActions.setAudioSettings({audioMode: HMSAudioMode.MUSIC}) // To toggle off music mode await hmsActions.setAudioSettings({audioMode: HMSAudioMode.VOICE})

Using the React SDK:

import { useState } from 'React' import { HMSAudioMode } from '@100mslive/hms-video-store'; import { useHMSActions } from '@100mslive/react-sdk'; const ToggleMusicMode = () => { const hmsActions = useHMSActions(); const [enabled, setEnabled] = useState(false); return <button onClick={async() => { await hmsActions.setAudioSettings({audioMode: enabled ? HMSAudioMode.VOICE : HMSAudioMode.MUSIC}); setEnabled(prev => !prev) }}> Enable music mode </button> }

Have a suggestion? Recommend changes ->

Was this helpful?