MLAudioType

class NatML.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

/// <summary>
/// Create an audio feature type.
/// <summary>
/// <param name="sampleRate">Sample rate</param>
/// <param name="channelCount">Channel count</param>
/// <param name="sampleCount">Total sample count.</param>
/// <param name="name">Feature name.</param>
MLAudioType (int sampleRate, int channelCount, int sampleCount, string name = default);

The audio type can be created with a sampleRate, channelCount, total sampleCount, and optional name.

From an Audio File

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

INCOMPLETE.

From an AudioClip

/// <summary>
/// Get the audio type for an audio clip.
/// </summary>
/// <param name-"clip">Audio clip.</param>
/// <returns>Corresponding audio type.</returns>
static MLAudioType FromAudioClip (AudioClip clip);

INCOMPLETE.

From a VideoClip

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

INCOMPLETE.

From Streaming Assets

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

INCOMPLETE.

Inspecting the Type

/// <summary>
/// Feature name.
/// </summary>
string name { get; }

/// <summary>
/// Feature data type.
/// This will typically be a numeric type.
/// </summary>
Type dataType { get; }

Refer to the MLFeatureType class for more information.

The dataType is always equal to typeof(float).

Inspecting the Format

Sample Rate

/// <summary>
/// Audio sample rate.
/// </summary>
int sampleRate { get; }

The audio type provides information about the audio feature's sample rate.

Channel Count

/// <summary>
/// Audio channel count.
/// </summary>
int channelCount { get; }

The audio type provides information about the audio feature's channel count.

Last updated