NatCorder
Search…
AudioInput
class NatML.Recorders.Inputs.AudioInput
The AudioInput simplifies the process of recording game audio from Unity.
The AudioInput is not supported on WebGL because because Unity does not support the OnAudioFilterRead message on WebGL.

Creating the Audio Input

The audio input can be created with either an AudioSource or an AudioListener:

With an Audio Listener

/// <summary>
/// Create an audio recording input from a scene's AudioListener.
/// </summary>
/// <param name="recorder">Media recorder to receive committed frames.</param>
/// <param name="clock">Clock for generating timestamps.</param>
/// <param name="listener">Audio listener for the current scene.</param>
AudioInput (IMediaRecorder recorder, IClock clock, AudioListener listener);
The audio input is created with a recorder to receive frames, along with a recording clock to generate timestamps. There is a corresponding constructor which does not accept a clock, for recorders that do not use audio timestamps:
/// <summary>
/// Create an audio recording input from a scene's AudioListener.
/// </summary>
/// <param name="recorder">Media recorder to receive audio frames.</param>
/// <param name="listener">Audio listener for the current scene.</param>
AudioInput (IMediaRecorder recorder, AudioListener listener);

With an Audio Source

/// <summary>
/// Create an audio recording input from an AudioSource.
/// </summary>
/// <param name="recorder">Media recorder to receive committed frames.</param>
/// <param name="clock">Clock for generating timestamps.</param>
/// <param name="audioSource">Audio source to record.</param>
/// <param name="mute">Optional. Mute audio source while recording so that it is not heard in scene.</param>
AudioInput (IMediaRecorder recorder, IClock clock, AudioSource source, bool mute = false);
The audio input is created with a recorder to receive frames, along with a recording clock to generate timestamps. The audio source can optionally be muted once audio has been sent to the recorder, using the mute flag. There is a corresponding constructor which does not accept a clock, for recorders that do not use audio timestamps:
/// <summary>
/// Create an audio recording input from an AudioSource.
/// </summary>
/// <param name="recorder">Media recorder to receive audio frames.</param>
/// <param name="source">Audio source to record.</param>
/// <param name="mute">Optional. Mute audio source while recording so that it is not heard in scene.</param>
AudioInput (IMediaRecorder recorder, AudioSource source, bool mute = false);
When recording from an AudioSource, make sure that both Bypass Effects and Bypass Listener Effects are disabled in the editor. If any is enabled, no audio will be recorded.

Disposing the Input

/// <summary>
/// Stop recorder input and release resources.
/// </summary>
void Dispose ();
When you choose to stop recording, simply dispose the recorder input. You will typically do this before calling FinishWriting on the recorder.
Copy link
On this page
Creating the Audio Input
With an Audio Listener
With an Audio Source
Disposing the Input