AudioComponentSource
namespace VideoKit.Sources {
/// <summary>
/// Media source for generating audio buffers from an `AudioSource` or `AudioListener` component.
/// </summary>
class AudioComponentSource : IDisposable { ... }
}
The audio component source generates AudioBuffer
instances
by capturing audio data from Unity Engine, via an AudioSource
or AudioListener
component.
Creating an Audio Component Source
The audio component source is created with a handler or recorder to receive
generated AudioBuffer
instances.
From an Audio Listener
/// <summary>
/// Create an audio buffer source from an AudioListener.
/// </summary>
/// <param name="listener">Audio listener to record.</param>
/// <param name="handler">Handler to receive audio buffers.</param>
/// <param name="clock">Clock for generating timestamps.</param>
AudioComponentSource (
AudioListener listener,
Action<AudioBuffer> handler,
IClock? clock = null
);
The audio component source can be created to capture AudioBuffer
instances
from an AudioListener
and send them to a provided handler
. To produce audio buffers with timestamps, an IClock
instance can be provided.
From an Audio Source
/// <summary>
/// Create an audio buffer source from an AudioSource.
/// </summary>
/// <param name="source">Audio source to record.</param>
/// <param name="handler">Handler to receive audio buffers.</param>
/// <param name="clock">Clock for generating timestamps.</param>
AudioComponentSource (
AudioSource source,
Action<AudioBuffer> handler,
IClock? clock = null
);
The audio component source can be created to capture AudioBuffer
instances
from an AudioSource
and send them to a provided handler
. To produce audio buffers with timestamps, an IClock
instance can be provided.
Disposing the Source
/// <summary>
/// Stop the audio component source and release resources.
/// </summary>
void Dispose ();
This method stops the audio component source from generating additional AudioBuffer
instances and releases resources.