Table of Contents

Class MicrophoneSource

Namespace
LiveKit

An audio source which captures from the device's microphone.

public sealed class MicrophoneSource : RtcAudioSource, IDisposable
Inheritance
MicrophoneSource
Implements
Inherited Members
Extension Methods

Remarks

Ensure microphone permissions are granted before calling Start().

Constructors

MicrophoneSource(string, GameObject)

Creates a new microphone source for the given device.

public MicrophoneSource(string deviceName, GameObject sourceObject)

Parameters

deviceName string

The name of the device to capture from. Use Microphone.devices to get the list of available devices.

sourceObject GameObject

The GameObject to attach the AudioSource to. The object must be kept in the scene for the duration of the source's lifetime.

Methods

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool

~MicrophoneSource()

protected ~MicrophoneSource()

Start()

Begins capturing audio from the microphone.

public override void Start()

Remarks

Ensure microphone permissions are granted before calling this method by calling Application.RequestUserAuthorization.

Exceptions

InvalidOperationException

Thrown when the microphone is not available or unauthorized.

Stop()

Stops capturing audio from the microphone.

public override void Stop()

Events

AudioRead

Event triggered when audio samples are captured from the underlying source. Provides the audio data, channel count, and sample rate.

public override event Action<float[], int, int> AudioRead

Event Type

Action<float[], int, int>

Remarks

This event is not guaranteed to be called on the main thread.