Unity
  • NatML for Unity
  • Preliminaries
    • Getting Started
    • Requirements
  • Workflows
    • Core Concepts
    • Fetching Models
    • Using Predictors
  • Authoring
    • Creating Predictors
    • Distributing Predictors
  • API Reference
    • IMLPredictor
    • MLModel
      • MLEdgeModel
        • Configuration
      • MLCloudModel
    • MLFeature
      • MLArrayFeature
      • MLImageFeature
      • MLStringFeature
      • MLAudioFeature
      • MLVideoFeature
      • MLDepthFeature
      • MLXRCpuDepthFeature
    • MLFeatureType
      • MLArrayType
      • MLAudioType
      • MLImageType
      • MLVideoType
      • MLStringType
    • MLPredictorExtensions
  • Integrations
    • Media Devices
    • Augmented Reality
    • Video Recording
  • Insiders
    • Changelog
    • Open Source
    • GitHub
    • Discord
    • Blog
Powered by GitBook
On this page
  • Creating the Type
  • From Audio Info
  • From an Audio File
  • From an AudioClip
  • From a VideoClip
  • From Streaming Assets
  • Inspecting the Type
  • Inspecting the Format
  • Sample Rate
  • Channel Count

Was this helpful?

  1. API Reference
  2. MLFeatureType

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.

/// <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.

/// <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; }

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.

PreviousMLArrayTypeNextMLImageType

Last updated 2 years ago

Was this helpful?

From an

From a

Refer to the class for more information.

AudioClip
VideoClip
MLFeatureType