RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • audioinfo
    • audioread

audioread — Read audio samples from a file.

audioread(filename) decodes an N-by-C sample tensor, where rows are frames and columns are channels. [y, Fs] = audioread(filename) also returns the double sample rate in Hz.

Syntax

y = audioread(filename)
[y, Fs] = audioread(filename)
y = audioread(filename, samples)
[y, Fs] = audioread(filename, samples)
y = audioread(filename, datatype)
[y, Fs] = audioread(filename, samples, datatype)

Inputs

filename
Type
StringScalar
Required
Yes
Description
Audio file path.
samples
Type
NumericArray
Required
No
Description
One-based inclusive frame range [first last].
datatype
Type
StringScalar
Required
Yes
Description
Output class: double or native.
datatype
Type
StringScalar
Required
No
Default
"double"
Description
Output class; "native" preserves representable source classes.
NameTypeRequiredDefaultDescription
filenameStringScalarYes—Audio file path.
samplesNumericArrayNo—One-based inclusive frame range [first last].
datatypeStringScalarYes—Output class: double or native.
datatypeStringScalarNo"double"Output class; "native" preserves representable source classes.

Returns

y
Type
NumericArray
Description
Decoded samples as an N-by-C matrix.
Fs
Type
NumericScalar
Description
Sample rate in Hz.
NameTypeDescription
yNumericArrayDecoded samples as an N-by-C matrix.
FsNumericScalarSample rate in Hz.

Returned values from audioread depend on how many outputs the caller requests.

Errors

RunMat:audioread:InvalidArgument
When
Filename, sample range, datatype, or output count is invalid.
Message
audioread: invalid argument
RunMat:audioread:Io
When
The audio file cannot be read.
Message
audioread: unable to read file
RunMat:audioread:UnsupportedFormat
When
The file is not a supported audio container, uses unsupported audio coding, or is malformed.
Message
audioread: unsupported or invalid audio file
IdentifierWhenMessage
RunMat:audioread:InvalidArgumentFilename, sample range, datatype, or output count is invalid.audioread: invalid argument
RunMat:audioread:IoThe audio file cannot be read.audioread: unable to read file
RunMat:audioread:UnsupportedFormatThe file is not a supported audio container, uses unsupported audio coding, or is malformed.audioread: unsupported or invalid audio file

Inputs and range

Filenames are scalar strings, singleton string arrays, or one-row character arrays read through the active filesystem provider. The optional two-element double sample range is one-based and inclusive: audioread(filename, [first last]). Inf as the last endpoint reads through the final frame; typed-integer ranges reject.

The datatype argument is double (default) or native. It may follow the filename directly or a sample range. At most two outputs are available; a zero-output statement still reads and decodes.

Decoding and classes

WAV/RF64 PCM 8-bit unsigned, PCM 16/24/32-bit signed, IEEE 32/64-bit float, and WAVE_FORMAT_EXTENSIBLE PCM/float subformats are decoded. FLAC, MP3, Ogg/Vorbis, and AIFF metadata can be inspected by audioinfo, but their samples are not decoded here.

Default PCM output is normalized double: unsigned 8-bit maps around zero and signed PCM divides by signed full scale. Native integer storage follows the sample container width: uint8 for 8-bit unsigned PCM, int16 for 16-bit signed PCM, and int32 for 24/32-bit signed PCM; 24-bit containers are left-aligned in int32. Extensible PCM may have fewer valid bits left-aligned inside a wider container, such as 24 valid bits in a 32-bit int32 sample. Native IEEE float32 returns single and float64 returns double. Sample tensors are column-major N-by-C, including N-by-1 mono.

Execution

Filesystem I/O and decoding execute on the host, terminate fusion, and create host-resident tensors. No provider kernel runs; GPU-resident arguments reject before provider access. Use gpuArray explicitly after reading if subsequent computation should reside on a device.

The active native, browser, sandbox, or remote filesystem provider must supply the input bytes. A filename is not a transferable file snapshot, so distributed workers require their own accessible file and filesystem capability.

With a seekable filesystem handle, WAV/RF64 sample ranges are read from selected frames in bounded input chunks. Providers that support whole-file reads but not seekable handles use the read fallback. The returned tensor occupies memory proportional to requested frames and channels; providers may have additional internal buffering costs.

When a finite host-memory budget is active, the complete read-and-decode call is admitted before opening the file. If the installed host resource service cannot establish complete bounds for the captured filesystem and decoder, the call fails without reading the file. Calls without a finite host-memory budget retain the ordinary reading path when no measured route is selected.

Examples

Read samples and sample rate

[y, Fs] = audioread('speech.wav');
size(y)
Fs

Expected output:

ans = 2 1
Fs = 8000

Read a one-based inclusive frame range

clip = audioread('speech.wav', [2 Inf]);
clip

Expected output:

clip = 0.5

Preserve native PCM16 storage

raw = audioread('speech.wav', 'native');
class(raw)

Expected output:

ans = int16

Using audioread with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how audioread changes the result.

Run a small audioread example, explain the result, then change one input and compare the output.

FAQ

What shape does audioread return?⌄

An N-by-C tensor: N decoded sample frames and C channels; mono is N-by-1.

Does it use the active filesystem provider?⌄

Yes. Native, sandbox, remote, and browser providers can supply file bytes when installed by the host.

Does it decode MP3 or FLAC samples?⌄

Not yet. audioinfo reads metadata for those containers; audioread currently decodes WAV/RF64 PCM and IEEE float.

Related Io functions

Audio

audioinfo

Net

accept · read · readline · tcpclient · tcpserver · write

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

Io

clc · diary · disp · display · format · input

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

Archive

gunzip · gzip · unzip

Hdf5

h5disp · h5info · h5read · h5write · h5writeatt · hdf5info · hdf5read · hdf5write

Import

importdata · textscan

Json

jsondecode · jsonencode

Mat

load · matfile · matlab.io.MatFile.subsasgn · matlab.io.MatFile.subsref · save

Http

sendmail · urldecode · urlencode · weboptions · webread · websave · webwrite

Source you can read

Every RunMat function's source is public. Read exactly how audioread is executed, line by line, in Rust.

  • View the source for audioread 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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Inputs and range
  • Decoding and classes
  • Execution
  • Examples
  • Read samples and sample rate
  • Read a one-based inclusive frame range
  • Preserve native PCM16 storage
  • Using audioread with coding agents
  • FAQ
  • Related Io functions
  • Audio
  • Net
  • Repl Fs
  • Tabular
  • Io
  • Data
  • Filetext
  • Archive
  • Hdf5
  • Import
  • Json
  • Mat
  • Http
  • Source you can read
  • About RunMat