NatML
Search…
MLAudioType
class NatSuite.ML.Types.MLAudioType : MLArrayType
The audio type describes audio buffers.

Creating the Type

The audio type can be created with audio information, or by inspecting an audio or video file:

From Audio Info

1
/// <summary>
2
/// Create an audio feature type.
3
/// <summary>
4
/// <param name="sampleRate">Sample rate</param>
5
/// <param name="channelCount">Channel count</param>
6
/// <param name="sampleCount">Total sample count.</param>
7
/// <param name="name">Feature name.</param>
8
MLAudioType (int sampleRate, int channelCount, int sampleCount, string name = default);
Copied!
The audio type can be created with a sampleRate, channelCount, total sampleCount, and optional name.

From an Audio File

1
/// <summary>
2
/// Get the audio type for an audio file at a given path.
3
/// </summary>
4
/// <param name="path">Audio path.</param>
5
/// <returns>Corresponding audio type or `null` if the file is not a valid audio file.</returns>
6
static MLAudioType FromFile (string path);
Copied!
INCOMPLETE.

From an AudioClip

1
/// <summary>
2
/// Get the audio type for an audio clip.
3
/// </summary>
4
/// <param name-"clip">Audio clip.</param>
5
/// <returns>Corresponding audio type.</returns>
6
static MLAudioType FromAudioClip (AudioClip clip);
Copied!
INCOMPLETE.

From a VideoClip

1
/// <summary>
2
/// Get the audio type for a video clip.
3
/// Note that the sample count is merely an estimate based on the duration of the video.
4
/// </summary>
5
/// <param name-"clip">Video clip.</param>
6
/// <param name-"track">Audio track index.</param>
7
/// <returns>Corresponding audio type or `null` if the video does not have an audio track.</returns>
8
static MLAudioType FromVideoClip (VideoClip clip, int track = 0);
Copied!
INCOMPLETE.

From Streaming Assets

1
/// <summary>
2
/// Get the audio type for an audio file in the `StreamingAssets` folder.
3
/// </summary>
4
/// <param name="relativePath">Relative path to audio file in `StreamingAssets` folder.</param>
5
/// <returns>Corresponding audio type or `null` if the file is not a valid audio file.</returns>
6
static Task<MLAudioType> FromStreamingAssets (string relativePath);
Copied!
INCOMPLETE.

Inspecting the Type

1
/// <summary>
2
/// Feature name.
3
/// </summary>
4
string name { get; }
5
6
/// <summary>
7
/// Feature data type.
8
/// This will typically be a numeric type.
9
/// </summary>
10
Type dataType { get; }
Copied!
Refer to the MLFeatureType class for more information.
The dataType is always equal to typeof(float).

Inspecting the Format

Sample Rate

1
/// <summary>
2
/// Audio sample rate.
3
/// </summary>
4
int sampleRate { get; }
Copied!
The audio type provides information about the audio feature's sample rate.

Channel Count

1
/// <summary>
2
/// Audio channel count.
3
/// </summary>
4
int channelCount { get; }
Copied!
The audio type provides information about the audio feature's channel count.