# MLAudioType

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

```csharp
/// <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

```csharp
/// <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`](https://docs.unity3d.com/ScriptReference/AudioClip.html)

```csharp
/// <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`](https://docs.unity3d.com/ScriptReference/Video.VideoClip.html)

```csharp
/// <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

```csharp
/// <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

```csharp
/// <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`](/unity/api/mlfeaturetype.md) class for more information.

{% hint style="info" %}
The `dataType` is always equal to `typeof(float)`.
{% endhint %}

## Inspecting the Format

### Sample Rate

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

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

### Channel Count

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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.natml.ai/unity/api/mlfeaturetype/mlaudiotype.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
