Create object for playing audio
player = audioplayer(Y,Fs)
player = audioplayer(Y,Fs,nBits)
player = audioplayer(Y,Fs,nBits,ID)
player = audioplayer(recorder)
player = audioplayer(recorder,ID)
creates
an player
= audioplayer(Y
,Fs
)audioplayer
object for signal Y
,
using sample rate Fs
. The function returns a handle
to the audioplayer
object, player
.
uses player
= audioplayer(Y
,Fs
,nBits
)nBits
bits
per sample for signal Y
.
uses
the audio device identified by player
= audioplayer(Y
,Fs
,nBits
,ID
)ID
for output.
creates
an player
= audioplayer(recorder
)audioplayer
object using audio recorder object recorder
.
creates
an object from player
= audioplayer(recorder
,ID
)recorder
that uses the audio device
identified byID
for output.
|
Audio signal represented by a vector or two-dimensional array
containing The value range of the input sample depends on the data type. The following table lists these ranges.
| ||||||||||||
| Sampling rate in Hz. Valid values depend on both the sample rates permitted by MATLAB® and the specific audio hardware on your system. MATLAB has a hard restriction of 1000 Hz <= Fs <= 384000 Hz, although further hardware-dependent restrictions apply. Typical values supported by most sound cards are 8000, 11025, 22050, 44100, 48000, and 96000 Hz. | ||||||||||||
|
Bits per sample. Specify only when signal Default: | ||||||||||||
|
Device identifier. To obtain the ID of a device, use the Default: | ||||||||||||
|
Audio recorder object created by |
Note:
When calling any method, include the |
Query properties of | |
| Query whether playback is in progress: returns |
| Pause playback. |
Play audio from beginning to end. | |
Play, and do not return control until playback completes. | |
| Restart playback from paused position. |
Set properties of | |
| Stop playback. |
See the reference pages for get
, play
, playblocking
,
and set
for
additional syntax options.
BitsPerSample | Number of bits per sample. (Read-only) |
CurrentSample | Current sample that the audio output device is playing.
If the device is not playing, |
DeviceID | Identifier for audio device. (Read-only) |
NumberOfChannels | Number of audio channels. (Read-only) |
Running | Status of the audio player: |
SampleRate | Sampling frequency in Hz. |
TotalSamples | Total length of the audio data in samples. (Read-only) |
Tag | Label of the object. |
Type | Name of the class: |
UserData | Any type of additional data to store with the object. |
The following four properties apply to callback functions.
The first two inputs to your callback function must be the audioplayer
object
and an event
structure.
StartFcn | Function to execute one time when playback starts. |
StopFcn | Function to execute one time when playback stops. |
TimerFcn | Function to execute repeatedly during playback. To specify
time intervals for the repetitions, use the |
TimerPeriod | Time in seconds between |
Load and play a sample audio file of Handel's "Hallelujah Chorus:"
load handel; player = audioplayer(y, Fs); play(player);