Skip to main content
Version: 2.0.x

Custom Audio Sources - iOS

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.

How to Create Custom Audio Track ?​

  • You can create a Audio Track using createAudioTrack() method of VideoSDK class.

  • This method can be used to create audio track using different noise configurations.

Example​

guard let audioMediaTrack = try? VideoSDK.createAudioTrack(
noiseConfig: noiseConfig(
// It is used to improve the quality of audio by removing background noise
// that can interfere with the clarity of speech.
noiseSupression: true,

// It is used to remove unwanted echoes from voice.
echoCancellation: true,

// It is used to maintain a consistent level of loudness or amplitude in a voice.
autoGainControl: true,

// It removes low frequency sounds hence making the audio clearer.
highPassFilter: true
)
) else {return}

How to Setup Custom Audio Track ?​

The custom track can be set up both before and after the initialization of the meeting.

  1. Setting up a Custom Track during the initialization of a meeting
  2. Setting up a Custom Track with methods
1. Setting up a Custom Track during the initialization of a 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.

caution

Custom Track will not apply on micEnabled: false configuration.

Example​
guard let customAudioStream = try? VideoSDK.createAudioTrack(
noiseConfig: noiseConfig(
noiseSupression: true,
echoCancellation: true,
autoGainControl: true,
highPassFilter: true
)
) else {return}

let meeting = VideoSDK.initMeeting(
meetingId: meetingId,
participantName: name,
micEnabled: true, // when passed true, it creates an audio track with defined configs
webcamEnabled: cameraEnabled // optional, default: true

// Pass the custom audio track here which will be used to when mic is auto started
customAudioStream: customAudioStream
)

2. Setting up a Custom Track with methods​

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

tip

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

Example​
@IBAction func unmuteButtonTapped(_ sender: Any) {
if !on {
guard
let audioMediaTrack = try? VideoSDK.createAudioTrack(
noiseConfig: noiseConfig(
noiseSupression: true,
echoCancellation: true,
autoGainControl: true,
highPassFilter: true
)
)
else { return }

self.meeting?.unmuteMic(customAudioStream: audioMediaTrack)
} else {
self.meeting?.muteMic()
}
}

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