audioinfo — Read metadata from an audio file.
info = audioinfo(filename) returns a MATLAB-style metadata structure for supported audio containers.
Syntax
info = audioinfo(filename)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
filename | StringScalar | Yes | — | Audio file path. |
Returns
| Name | Type | Description |
|---|---|---|
info | Any | Audio metadata structure. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:audioinfo:InvalidArgument | Filename is missing or cannot be interpreted as a scalar path. | audioinfo: invalid filename |
RunMat:audioinfo:Io | The audio file cannot be read. | audioinfo: unable to read file |
RunMat:audioinfo:UnsupportedFormat | The file is not a supported audio container or has malformed metadata. | audioinfo: unsupported or invalid audio file |
How audioinfo works
- Accepts scalar string, scalar string-array, or row character-vector filenames and reads through RunMat's filesystem abstraction.
- Recognizes WAV/RF64 RIFF containers, FLAC STREAMINFO metadata, AIFF/AIFC COMM metadata, Ogg/Vorbis identification headers, and MPEG audio frame headers.
- Returns stable fields:
Filename,CompressionMethod,NumChannels,SampleRate,TotalSamples,Duration,BitsPerSample,BitRate,FileSize, andFormat. TotalSamples,Duration,BitsPerSample, orBitRateareNaNwhen the container does not expose enough information in headers alone.- For MP3 files, metadata is estimated from the first valid MPEG audio frame header after an optional ID3v2 tag. Variable-rate files may require future decoder support for exact duration.
- Malformed or unsupported audio files raise a descriptive format error rather than returning partial metadata.
Does RunMat run audioinfo on the GPU?
audioinfo does not launch provider kernels or participate in fusion. It reads audio container headers from the active filesystem provider and constructs a metadata struct on the host.
GPU memory and residency
audioinfo is a host file-I/O operation and returns a host struct. No GPU residency is created or consumed.
Examples
Read WAV metadata
info = audioinfo("sample.wav");
info.SampleRate
info.NumChannelsUse duration and total sample count
info = audioinfo("speech.flac");
seconds = info.Duration;
frames = info.TotalSamples;Using audioinfo with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how audioinfo changes the result.
Run a small audioinfo example, explain the result, then change one input and compare the output.
FAQ
Does audioinfo decode audio samples?⌄
No. It reads container metadata only. Sample decoding belongs to audioread.
Which formats are supported?⌄
WAV/RF64, FLAC, AIFF/AIFC, Ogg/Vorbis, and MPEG audio frame headers, including common MP3 files.
Why are some fields NaN?⌄
Some compressed formats do not expose exact sample count, bit depth, or duration in their primary headers. RunMat preserves the field shape and uses NaN for unavailable metadata.
Related Io functions
Audio
Repl Fs
addpath · cd · copyfile · delete · dir · exist · fullfile · genpath · getenv · ls · mkdir · movefile · path · pwd · rmdir · rmpath · run · savepath · setenv · tempdir · tempname · uigetfile · uiputfile
Tabular
csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · readmatrix · spreadsheetImportOptions · writecell · writematrix · xlsread
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite
Import
Json
Archive
Http
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how audioinfo is executed, line by line, in Rust.
- View the source for audioinfo in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.