createMicrophoneAudioTrack static method
dynamic
createMicrophoneAudioTrack({
- String? microphoneId,
- CustomAudioTrackConfig encoderConfig = CustomAudioTrackConfig.speech_standard,
- Map<
String, bool> noiseConfig = const {},
Creates a microphone-based audio track with customizable encoding and noise-cancellation settings.
This method allows you to create a custom audio track using a microphone device, with support for different audio quality profiles and optional noise control configurations.
Parameters
-
microphoneId(optional): The device ID of the microphone from which audio should be captured. If not provided, the default microphone will be used. -
encoderConfig(optional): The audio encoder configuration to be used for the audio track. Defaults to CustomAudioTrackConfig.speech_standard.Allowed values:
-
noiseConfig(optional): Configuration options for controlling audio noise processing.Supported properties:
echoCancellation: Enables or disables echo cancellation.autoGainControl: Enables or disables automatic gain control.noiseSuppression: Enables or disables noise suppression.
Returns
- A Future that resolves to a CustomTrack representing the
created audio track, or
nullif audio track creation fails.
Example
final CustomTrack? audioTrack =
await VideoSDK.createMicrophoneAudioTrack(
encoderConfig: CustomAudioTrackConfig.high_quality,
);
if (audioTrack != null) {
print('Audio track created successfully');
}
Implementation
static createMicrophoneAudioTrack(
{String? microphoneId,
CustomAudioTrackConfig encoderConfig =
CustomAudioTrackConfig.speech_standard,
Map<String, bool> noiseConfig = const {}}) =>
_createMicrophoneAudioTrack(
microphoneId: microphoneId,
encoderConfig: encoderConfig,
noiseConfig: noiseConfig);