en fr

Disponible uniquement en anglais

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Audio Playback

This section describes functions which play sounds. Currently, these functions are available on Windows and macOS.



Play audio samples.


audioplay(samples, options)


audioplay(samples) plays the audio samples in array samples at a sample rate of 44.1 kHz. Each column of samples is a channel (i.e. samples is a column vector for monophonic sound and a two-column array for stereophonic sound), and each row is a sample. Samples are stored as double or single numbers between -1 and 1, int8 numbers between -128 and 127, or int16 numbers between -32768 and 32767.

audioplay(samples,options) uses the specified options, which are typically built with audioset or provided directly as named arguments.


A monophonic bell-like sound of two seconds with a frequency of 740 Hz and a damping time constant of 0.5 second:

t = (0:1/44100:2)';
samples = sin(2*pi*740*t).*exp(-t/0.5);

Some white noise which oscillates 5 times between left and right:

t = (0:1/44100:1)';
noise = 0.1 * randn(length(t), 1);
left = cos(2 * pi * t) .* noise;
right = sin(2 * pi * t) .* noise;
audioplay([left, right], Repeat=5);

See also



Options for audio.


options = audioset
options = audioset(name1=value1, ...)
options = audioset(name1, value1, ...)
options = audioset(options0, name1=value1, ...)
options = audioset(options0, name1, value1, ...)


audioset(name1,value1,...) creates the option argument used by audioplay. Options are specified with name/value pairs, where the name is a string which must match exactly the names in the table below. Case is significant. Options which are not specified have a default value. The result is a structure whose fields correspond to each option. Without any input argument, audioset creates a structure with all the default options. Note that audioplay also interprets the lack of an option argument, or the empty array [], as a request to use the default values.

When its first input argument is a structure, audioset adds or changes fields which correspond to the name/value pairs which follow.

Here is the list of permissible options:

Repeat1number of repetitions
SampleRate44100sample rate in Hz

Default values may be different on platforms with limited audio capabilities.


Default options:

  Repeat: 1
  SampleRate: 44100

See also