Skip to main content
Version: 0.0.x

Custom Audio Track

We have introduced the ability to pass a custom Audio track for the Audio of the participants. This feature can be used to add custom layers like background noise removal, echo cancellation, etc. on audio and send it to other participants.

Creating a Custom Audio Track

  • You can create a Audio Track using createAudioTrack() method of VideoSDK.
  • This method can be used to create audio track using different encoding parameters and noise cancellation configration.

Parameters

  • encoderConfig:

    • type: String
    • required: true
    • default: speech_standard
    • Allowed values : speech_low_quality | speech_standard | music_standard | standard_stereo | high_quality | high_quality_stereo
    • It will be the encoder configuration you want to use for Audio Track.
  • noiseConfig

    • type: JSONObject

    • required: true

    • acousticEchoCancellation

      • type: boolean
      • required: true
      • If true echo cancellation will turned on else it would be turned off.
    • autoGainControl

      • type: boolean
      • required: true
      • If true auto gain will turned on else it would be turned off.
    • noiseSuppression

      • type: boolean
      • required: true
      • If true noise suppression will turned on else it would be turned off.
  • context

    • type: Context
    • required: true
    • Pass the Android Context for this parameter.

Returns

  • CustomStreamTrack

Example

val noiseConfig = JSONObject()
try {
noiseConfig.put("acousticEchoCancellation", true)
noiseConfig.put("autoGainControl", true)
noiseConfig.put("noiseSuppression", true)

val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", noiseConfig, this)
} catch (e: JSONException) {
e.printStackTrace()
}

Using Custom Audio Track

Custom Track while initializing the meeting

If you are passing micEnabled: true in the initMeeting of VideoSDK and want to use custom tracks from start of the meeting, you can pass custom track in the initMeeting as shown below.

override fun onCreate(savedInstanceState: Bundle?) {
//..

val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()
val noiseConfig = JSONObject()
try {
noiseConfig.put("acousticEchoCancellation", true)
noiseConfig.put("autoGainControl", true)
noiseConfig.put("noiseSuppression", true)
} catch (e: JSONException) {
e.printStackTrace()
}

val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", noiseConfig, this)
customTracks["mic"] = audioCustomTrack //Key must be "mic"

// create a new meeting instance
val meeting = 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,
//Pass the custom tracks here
customTracks
)
}

Custom Track with unmuteMic()

In order to switch tracks during the meeting, you have to pass the CustomStreamTrack in the unmuteMic() method of Meeting.

You can also pass custom track in changeMic() method of Meeting.

note

Make sure to call muteMic() before you create a new track as it may lead to unexpected behaviour.

val noiseConfig = JSONObject()
try {
noiseConfig.put("acousticEchoCancellation", true)
noiseConfig.put("autoGainControl", true)
noiseConfig.put("noiseSuppression", true)

val audioCustomTrack: CustomStreamTrack = VideoSDK.createAudioTrack("high_quality", noiseConfig, this)
meeting!!.unmuteMic(audioCustomTrack)

//or
meeting!!.changeMic(AppRTCAudioManager.AudioDevice.BLUETOOTH, audioCustomTrack)
} catch (e: JSONException) {
e.printStackTrace()
}