Custom Audio Sources - Flutter
For a high-quality streaming experience, fine-tuning audio tracks becomes essential—especially when delivering content to a broader live audience.
To enhance your live audio pipeline, we've introduced the capability to provide a custom audio track for a hosts's stream both before and during a live session.
Custom Audio Track​
This feature allows you to integrate advanced audio layers like background noise suppression, echo cancellation, and more—so your stream sounds polished and professional to every viewer.
How to Create a Custom Audio Track ?
​
- You can create a Audio Track using
createMicrophoneAudioTrack()
method ofVideoSDK
class. - This method can be used to create audio track using different encoding parameters and noise cancellation configuration.
Example​
CustomTrack? audioTrack = await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomAudioTrackConfig.high_quality);
Here are different configurations for customizing audio tracks based on specific use cases:
speech_standard
: This config is optimised for normal voice communication.high_quality
: This config is used for obtaining RAW audio, allowing you to apply yournoiseConfig
.music_standard
: This config is optimised for communication scenarios, where the sharing of musical elements, such as songs or instrumental sounds, is crucial.
How to Setup Custom Audio Track ?
​
You can plug in your custom audio track either before going live or dynamically while the session is ongoing.
1. Setup during live stream initialization​
If you are passing micEnabled: true
in the createRoom
and want to use custom tracks from start of the livestream, you can pass custom track in the createRoom
as shown below.
CustomTrack? audioTrack = await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomAudioTrackConfig.high_quality);
Room room = VideoSDK.createRoom(
roomId: widget.livestreamId,
token: widget.token,
displayName: widget.displayName,
micEnabled: widget.micEnabled,
camEnabled: widget.camEnabled,
maxResolution: 'hd',
defaultCameraIndex: 1,
multiStream: false,
// Pass the custom track here
customMicrophoneAudioTrack: audioTrack, // custom audio track :: optional
notification: const NotificationInfo(
title: "Video SDK",
message: "Video SDK is sharing screen in the livestream",
icon: "notification_share", // drawable icon name
),
);
2. Setup dynamically using methods​
In order to switch tracks during the livestream, you have to pass the CustomTrack
in the room.unmuteMic()
method.
Make sure to call muteMic()
before you create a new track as it may lead to unexpected behavior.
CustomTrack? audioTrack = await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomAudioTrackConfig.high_quality);
room.unmuteMic(customTrack);
API Reference​
The API references for all the methods and events utilized in this guide are provided below.
Got a Question? Ask us on discord