audioinfo — Read metadata from an audio file.
info = audioinfo(filename) returns a metadata structure without decoding sample data.
Syntax
info = audioinfo(filename)Inputs
filename- Type
StringScalar- Required
- Yes
- Description
- Audio file path.
Returns
info- Type
Any- Description
- Audio metadata structure.
Errors
RunMat:audioinfo:InvalidArgument- When
- Filename is missing or cannot be interpreted as a scalar path.
- Message
audioinfo: invalid filename
RunMat:audioinfo:Io- When
- The audio file cannot be read.
- Message
audioinfo: unable to read file
RunMat:audioinfo:UnsupportedFormat- When
- The file is not a supported audio container or has malformed metadata.
- Message
audioinfo: unsupported or invalid audio file
Inputs and fields
The filename is scalar string, singleton string array, or one-row character array. The active filesystem provider supplies the file. The result is a host scalar structure with Filename, CompressionMethod, NumChannels, SampleRate, TotalSamples, Duration, BitsPerSample, BitRate, FileSize, and Format fields.
When headers do not establish a field, TotalSamples, Duration, BitsPerSample, or BitRate is NaN; the field is retained rather than omitted.
When the caller explicitly discards the result, audioinfo still reads and validates the file but does not construct or retain the metadata structure.
For WAVE_FORMAT_EXTENSIBLE, BitsPerSample reports valid sample precision; the encoded container may be wider. audioread(..., 'native') chooses its integer storage from the container width.
Containers and limits
WAV/RF64 RIFF, FLAC STREAMINFO, AIFF/AIFC COMM, Ogg/Vorbis identification headers, and MPEG audio frame headers are recognized. Malformed or unsupported data raises a format error rather than partial metadata.
MP3 information is estimated from the first valid MPEG frame header following an optional ID3v2 tag; variable-rate duration can differ from decoded duration. Inspection reads at most a 1 MiB prefix and, for larger Ogg files, an additional 64 KiB tail.
Execution
Metadata inspection is host filesystem I/O, a fusion boundary, and never a GPU kernel. It consumes no GPU-resident numeric input and returns a host struct. audioinfo does not decode samples; use audioread for supported WAV/RF64 sample payloads.
When a finite host-memory budget is active, the complete metadata call is admitted before opening the file. If the installed host resource service cannot establish complete bounds for the captured filesystem and metadata work, the call fails without reading the file. Calls without a finite host-memory budget retain the ordinary metadata path when no measured route is selected.
Examples
Read WAV metadata and duration
info = audioinfo('sample.wav');
info.SampleRate
info.NumChannels
seconds = info.Duration;
frames = info.TotalSamples;Expected output:
ans = 8000
ans = 1Inspect FLAC duration and sample count
info = audioinfo('speech.flac');
seconds = info.Duration;
frames = info.TotalSamples;
seconds
framesExpected output:
seconds = 2
frames = 96000Using 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 · fileattrib · fileparts · filesep · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · memmapfile.subsasgn · memmapfile.subsref · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite
Tabular
arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · getvaropts · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · setvaropts · setvartype · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite
Data
commit · data.copy · data.create · data.delete · data.exists · data.export · data.import · data.inspect · data.list · data.move · data.open · DataArray.chunk_shape · DataArray.codec · DataArray.dtype · DataArray.fill · DataArray.name · DataArray.rank · DataArray.read · DataArray.resize · DataArray.shape · DataArray.write · Dataset.array · Dataset.arrays · Dataset.attrs · Dataset.begin · Dataset.get_attr · Dataset.has_array · Dataset.id · Dataset.path · Dataset.refresh · Dataset.set_attr · Dataset.set_attrs · Dataset.snapshot · Dataset.version · DataTransaction.abort · DataTransaction.commit · DataTransaction.create_array · DataTransaction.delete_array · DataTransaction.fill · DataTransaction.id · DataTransaction.resize · DataTransaction.set_attr · DataTransaction.set_attrs · DataTransaction.status · DataTransaction.write
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines
Import
Json
Source you can read
Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.