Noise Cancellation
The Noise Cancellation feature is an invaluable tool designed to enhance the audio quality in scenarios such as conferences, live streams, and recordings where unwanted background noise can degrade the listening experience. By leveraging advanced Artificial Intelligence (AI) algorithms, this feature intelligently identifies and suppresses extraneous sounds, ensuring clear and crisp audio output.
Key Benefits
-
Enhanced Audio Quality: Eliminates unwanted noise, including background chatter, clicks, claps, barking, and other sudden audio disturbances, resulting in a more pleasant listening experience for your audience.
-
Improved Clarity: Ensures that the primary audio content remains prominent and intelligible by reducing distractions caused by ambient noise.
-
Optimized Communication: Facilitates seamless communication in conferences and live streams by minimizing disruptions caused by environmental factors, thereby enhancing the overall professionalism of the presentation.
How it Works
The Noise Cancellation feature employs a sophisticated AI model trained specifically to discern between desired audio signals and unwanted noise. Upon detecting extraneous sounds in the microphone input, the algorithm analyzes the audio waveform in real-time and generates an inverse sound wave, effectively canceling out the unwanted noise. This process occurs seamlessly and in near-real-time, preserving the integrity of the primary audio content without introducing noticeable delays.
Minimum Requirements
hmssdk_flutter
version 1.10.0 or higher is required to utilize the Noise Cancellation feature in your Flutter application.
IMPORTANT
Enable Noise Cancellation in the template configuration. Learn more about enabling this feature from here
Usage
HMSSDK provides HMSNoiseCancellationController
to control Noise Cancellation in your Rooms. HMSNoiseCancellationController
exposes several methods to enable, disable, and check the availability of Noise Cancellation etc. in the Room.
Step 1: Add Noise Cancellation library dependency (Android only)
Add the following dependency to your app's build.gradle
file to integrate the Noise Cancellation feature into your Flutter application:
dependencies { ... implementation "live.100ms:hms-noise-cancellation-android:2.9.67" }
Ensure that you add the above dependency in the dependencies
block of the my_app_name/android/app/build.gradle
file.
Check the reference here to see it in action in the sample app.
Replace 2.9.67
with the latest version of the Noise Cancellation library available on the Maven Repository.
This step is required only for the Android app. On iOS, the Noise Cancellation library is already integrated into the HMSSDK.
Step 2: Set the enableNoiseCancellation property in HMSAudioTrackSetting as true
/// To enable noise cancellation set the `enableNoiseCancellation` property to true var audioTrackSetting = HMSAudioTrackSetting( trackInitialState: joinWithMutedAudio ? HMSTrackInitState.MUTED : HMSTrackInitState.UNMUTED,
enableNoiseCancellation: true);
Step 3: Pass the Track Settings to the HMSSDK constructor
/// Create Instance of `HMSTrackSetting` var trackSettings = HMSTrackSetting( audioTrackSetting: HMSAudioTrackSetting(
enableNoiseCancellation: true),videoTrackSetting: HMSVideoTrackSetting( trackInitialState: joinWithMutedVideo ? HMSTrackInitState.MUTED : HMSTrackInitState.UNMUTED, )); /// Set the track settings to HMSSDK var hmsSDK = HMSSDK( hmsTrackSetting: trackSettings);
Step 4: Check for Noise Cancellation availability
🔑 Note: You can call this API to check the state of Noise Cancellation only after successfully joining the Room.
class Meeting implements HMSUpdateListener, HMSActionResultListener{ bool isNoiseCancellationAvailable = false; /// This method checks the noise cancellation availability void checkNoiseCancellationAvailability() async {
isNoiseCancellationAvailable = await HMSNoiseCancellationController.isAvailable();} }
Step 5: If Noise Cancellation is available, enable it
class Meeting implements HMSUpdateListener, HMSActionResultListener{ bool isNoiseCancellationAvailable = false; /// This method checks the Noise Cancellation availability void checkNoiseCancellationAvailability() async { isNoiseCancellationAvailable = await HMSNoiseCancellationController.isAvailable(); } /// This method enables Noise Cancellation if it's available void enableNoiseCancellation() { if(isNoiseCancellationAvailable){
HMSNoiseCancellationController.enable();} } }
Step 6: To disable Noise Cancellation use HMSNoiseCancellationController's disable method
class Meeting implements HMSUpdateListener, HMSActionResultListener{ bool isNoiseCancellationAvailable = false; /// This method checks the Noise Cancellation availability void checkNoiseCancellationAvailability() async { isNoiseCancellationAvailable = await HMSNoiseCancellationController.isAvailable(); } /// This method disables Noise Cancellation void disableNoiseCancellation() {
HMSNoiseCancellationController.disable();} }
That's it - you've successfully integrated the Noise Cancellation feature into your Flutter application using HMSSDK.
How to check whether Noise Cancellation is enabled in the Room
To check whether Noise Cancellation is enabled in the Room, you can use the HMSNoiseCancellationController's isEnabled
method as shown below:
class Meeting implements HMSUpdateListener, HMSActionResultListener{ bool isNoiseCancellationEnabled = false; /// is noise cancellation enabled void isNoiseCancellationEnabled() async{
isNoiseCancellationEnabled = await HMSNoiseCancellationController.isEnabled();} }