MATLAB Function Reference Previous page   Next Page
audioplayer

Create audio player object

Syntax

Description

y = audioplayer(x,Fs) returns a handle to an audio player object y using input audio signal x. The audio player object supports methods and properties that you can use to play audio data.

The input signal x can be a vector or two-dimensional array containing single, double, int8, uint8, or int16 MATLAB data types. The input sample value range depends on the MATLAB data type.

Data Type
Input Sample Value Range
int8
-128 to 127
uint8
0 to 255
int16
-32768 to 32767
single
-1 to 1
double
-1 to 1

Fs is the sampling rate in Hz to use for playback. Valid values for Fs depend on the specific audio hardware installed. Typical values supported by most sound cards are 8000, 11025, 22050, and 44100 Hz.

y = audioplayer(x,Fs,nbits) returns a handle to an audio player object where nbits is the bit quantization to use for single or double data types. This is an optional parameter with a default value of 16. Valid values for nbits are 8 and 16 (and 24, if a 24-bit device is installed). You do not need to specify nbits for int8, uint8, or int16 data because the quantization is set automatically to 8 or 16, respectively.

y = audioplayer(r) returns a handle to an audio player object from an audiorecorder object r.

y = audioplayer(r,id) returns a handle to an audio player object from an audiorecorder object r, using the audio device specified by id for output. This option is only available on systems running Windows

Example

Load a sample audio file, create an audio player object, and play the audio at a higher sampling rate. x contains the audio samples and Fs is the sampling rate. You can use any of the audioplayer functions listed above on the player.

To stop the playback, use this command:

Methods

After you create an audio player object, you can use the methods listed below on that object. y represents the name of the returned audio player.

Method
Description
play(y)
play(y,start)
play(y,[start stop])
play(y,range)
Starts playback from the beginning and plays to the end, or from start sample to the end, or from start sample to stop sample. The values of start and stop can be specified in a two-element vector range.
playblocking(y)
playblocking(y,start)
playblocking(y,[start stop])
playblocking(y,range)
Same as play, but does not return control until playback completes.
stop(y)
Stops playback.
pause(y)
Pauses playback.
resume(y)
Restarts playback from where playback was paused.
isplaying(y)
Indicates whether playback is in progress. If 0, playback is not in progress. If 1, playback is in progress.
display(y)
disp(y)
get(y)
Displays all property information about audio player y.

Properties

Audio player objects have the properties listed below. To set a user-settable property, use this syntax:

To view a read-only property,

See Also

audiorecorder, sound, wavplay, wavwrite, wavread, get, set, methods


Previous page  atanh audiorecorder Next page

© 1994-2005 The MathWorks, Inc.