Custom Audio Sources - Android
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 Custom Audio Track ?
​
-
You can create a Audio Track using
createAudioTrack()
method ofVideoSDK
. -
This method can be used to create audio track using different encoding parameters.
Example​
- Kotlin
- Java
val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("speech_standard",this)
// `high_quality` | `music_standard`, Default : `speech_standard`
CustomStreamTrack audioCustomTrack=VideoSDK.createAudioTrack("speech_standard", this);
// `high_quality` | `music_standard`, Default : `speech_standard`
-
speech_standard
: This config is optimised for normal voice communication. -
high_quality
: This config is used for getting RAW audio, where you can apply yournoiseConfig
. -
music_standard
: This config is optimised for communication, where sharing of musical notes such as songs or instrumental sounds, is important.
How to Setup Custom Audio Track ?
​
The custom track can be set up both before and after the initialization of the meeting.
- Setting up a Custom Track during the initialization of a meeting
- Setting up a Custom Track with methods
1. Setup during live stream initialization​
If you're starting the stream with the mic enabled (micEnabled: true)
and wish to use a custom track from the beginning, pass it through the config of MeetingProvider.
Custom Track will not apply on micEnabled: false
configuration.
Example​
- Kotlin
- Java
override fun onCreate(savedInstanceState: Bundle?) {
//..
val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()
val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", this)
customTracks["mic"] = audioCustomTrack //Key must be "mic"
// create a new meeting instance
val liveStream = VideoSDK.initMeeting(
this@MainActivity,meetingId,participantName,
//MicEnabled , If true, it will use the passed custom track to turn mic on
true,
//WebcamEnabled
true,
//ParticipantId
null,
//Mode
null,
//MultiStream
false,
//Pass the custom tracks here
customTracks,
//MetaData
null
)
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//..
Map<String, CustomStreamTrack> customTracks = new HashMap<>();
CustomStreamTrack audioCustomTrack = VideoSDK.createAudioTrack("high_quality", this);
customTracks.put("mic", audioCustomTrack); //Key must be "mic"
// create a new meeting instance
Meeting liveStream = VideoSDK.initMeeting(
MainActivity.this, meetingId, participantName,
//MicEnabled , If true, it will use the passed custom track to turn mic on
true,
//WebcamEnabled
true,
//ParticipantId
null,
//Mode
null,
//MultiStream
false,
//Pass the custom tracks here
customTracks,
//MetaData
null
);
}
2. Setup dynamically using methods​
During the live stream, you can update the audio source by passing the CustomStreamTrack
in the unmuteMic()
method of Meeting
.
You can also pass custom track in changeMic()
method of Meeting
.
Make sure to call the muteMic()
method before you create a new track as it may lead to unexpected behavior.
Example​
- Kotlin
- Java
try {
val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", this)
liveStream!!.unmuteMic(audioCustomTrack)
//or
liveStream!!.changeMic(AppRTCAudioManager.AudioDevice.BLUETOOTH, audioCustomTrack)
} catch (e: JSONException) {
e.printStackTrace()
}
try {
CustomStreamTrack audioCustomTrack = VideoSDK.createAudioTrack("high_quality", this);
liveStream.unmuteMic(audioCustomTrack);
//or
liveStream.changeMic(AppRTCAudioManager.AudioDevice.BLUETOOTH,audioCustomTrack);
}catch (JSONException e) {
e.printStackTrace();
}
API Reference​
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord