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)
player = audioplayer(recorder) creates an audioplayer object using audio recorder object recorder.
Audio signal represented by a vector or two-dimensional array containing single, double, int8, uint8, or int16 values.
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 the specific audio hardware installed. Typical values supported by most sound cards are 8000, 11025, 22050, 44100, 48000, and 96000 Hz.
Bits per sample. Specify only when signal Y is represented by floating-point values. Valid values depend on the audio hardware installed: 8, 16, or 24.
Device identifier. To obtain the ID of a device, use the audiodevinfo function.
Default: -1 (default device)
Audio recorder object created by audiorecorder.
Note: When calling any method, include the audioplayer object name using function syntax, such as stop(player).
Query properties of audioplayer object.
Query whether playback is in progress: returns true or false.
Play audio from beginning to end.
Play, and do not return control until playback completes.
Restart playback from paused position.
Set properties of audioplayer object.
Number of bits per sample. (Read-only)
Current sample that the audio output device is playing. If the device is not playing, CurrentSample is the next sample to play with play or resume. (Read-only)
Identifier for audio device. (Read-only)
Number of audio channels. (Read-only)
Status of the audio player: 'on' or 'off'. (Read-only)
Sampling frequency in Hz.
Total length of the audio data in samples. (Read-only)
String that labels the object.
Name of the class: 'audioplayer'. (Read-only)
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.
Function to execute one time when playback starts.
Function to execute one time when playback stops.
Function to execute repeatedly during playback. To specify time intervals for the repetitions, use the TimerPeriod property.
Time in seconds between TimerFcn callbacks. Default: .05
Load and play a sample audio file of Handel's "Hallelujah Chorus:"
load handel; player = audioplayer(y, Fs); play(player);