NatCorder
Search…
AudioInput
class NatSuite.Recorders.Inputs.AudioInput
The AudioInput class simplifies the process of recording game audio from Unity.

Creating the Input

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

From an Audio Listener

1
/// <summary>
2
/// Create an audio recording input from a scene's AudioListener.
3
/// </summary>
4
/// <param name="recorder">Media recorder to receive committed frames.</param>
5
/// <param name="clock">Clock for generating timestamps.</param>
6
/// <param name="listener">Audio listener for the current scene.</param>
7
AudioInput (IMediaRecorder recorder, IClock clock, AudioListener listener);
Copied!
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:
1
/// <summary>
2
/// Create an audio recording input from a scene's AudioListener.
3
/// </summary>
4
/// <param name="recorder">Media recorder to receive audio frames.</param>
5
/// <param name="listener">Audio listener for the current scene.</param>
6
AudioInput (IMediaRecorder recorder, AudioListener listener);
Copied!

From an Audio Source

1
/// <summary>
2
/// Create an audio recording input from an AudioSource.
3
/// </summary>
4
/// <param name="recorder">Media recorder to receive committed frames.</param>
5
/// <param name="clock">Clock for generating timestamps.</param>
6
/// <param name="audioSource">Audio source to record.</param>
7
/// <param name="mute">Optional. Mute audio source while recording so that it is not heard in scene.</param>
8
AudioInput (IMediaRecorder recorder, IClock clock, AudioSource source, bool mute = false);
Copied!
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:
1
/// <summary>
2
/// Create an audio recording input from an AudioSource.
3
/// </summary>
4
/// <param name="recorder">Media recorder to receive audio frames.</param>
5
/// <param name="source">Audio source to record.</param>
6
/// <param name="mute">Optional. Mute audio source while recording so that it is not heard in scene.</param>
7
AudioInput (IMediaRecorder recorder, AudioSource source, bool mute = false);
Copied!
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

1
/// <summary>
2
/// Stop recorder input and release resources.
3
/// </summary>
4
void Dispose ();
Copied!
When you choose to stop recording, simply dispose the recorder input. You will typically do this before calling FinishWriting on the recorder.