Table of Contents

Class PlatformAudioSource

Namespace
LiveKit

Audio source that captures from the platform microphone via WebRTC's ADM.

Unlike MicrophoneSource which uses Unity's Microphone API and manually pushes audio frames, PlatformAudioSource lets WebRTC's ADM handle capture directly. This provides:

  • Echo cancellation (AEC) that works with speaker playout
  • Lower latency (single audio path, no Unity intermediate)
  • Automatic gain control and noise suppression

Requires PlatformAudio to be created first to enable the ADM.

public sealed class PlatformAudioSource : IRtcSource, IDisposable
Inheritance
PlatformAudioSource
Implements
Inherited Members
Extension Methods

Examples

// Create PlatformAudio first (enables ADM)
var platformAudio = new PlatformAudio();

// Create audio source with default options
var source = new PlatformAudioSource(platformAudio);

// Or with custom options
var options = new AudioProcessingOptions {
    EchoCancellation = true,
    NoiseSuppression = true,
    AutoGainControl = true,
    PreferHardware = true
};
var source = new PlatformAudioSource(platformAudio, options);

// Create and publish track
var track = LocalAudioTrack.CreateAudioTrack("microphone", source, room);
await room.LocalParticipant.PublishTrack(track, options);

Constructors

PlatformAudioSource(PlatformAudio)

Creates a new platform audio source with default audio processing options.

The source will capture audio from the microphone selected via PlatformAudio.SetRecordingDevice(), or the default device if none selected.

public PlatformAudioSource(PlatformAudio platformAudio)

Parameters

platformAudio PlatformAudio

The PlatformAudio instance. Must be kept alive while this source is in use.

Exceptions

ArgumentNullException

Thrown if platformAudio is null.

PlatformAudioSource(PlatformAudio, AudioProcessingOptions)

Creates a new platform audio source with custom audio processing options.

The source will capture audio from the microphone selected via PlatformAudio.SetRecordingDevice(), or the default device if none selected.

public PlatformAudioSource(PlatformAudio platformAudio, AudioProcessingOptions options)

Parameters

platformAudio PlatformAudio

The PlatformAudio instance. Must be kept alive while this source is in use.

options AudioProcessingOptions

Audio processing options to configure on the ADM.

Exceptions

ArgumentNullException

Thrown if platformAudio is null.

Properties

Muted

Whether the audio source is muted.

public override bool Muted { get; }

Property Value

bool

Methods

Dispose()

Releases the audio source resources.

public void Dispose()

SetMute(bool)

Mutes or unmutes the audio source.

public override void SetMute(bool muted)

Parameters

muted bool

True to mute, false to unmute.