Main Content

play

Play audio from audiorecorder object

Syntax

player = play(recObj)
player = play(recObj, start)
player = play(recObj, [start stop])

Description

player = play(recObj) plays the audio associated with audiorecorder object recObj from beginning to end, and returns an audioplayer object.

player = play(recObj, start) plays audio from the sample indicated by start to the end.

player = play(recObj, [start stop]) plays audio from the sample indicated by start to the sample indicated by stop.

Examples

Record 5 seconds of your speech with a microphone, and play it back. Display the properties of the audioplayer object.

myVoice = audiorecorder;

disp('Start speaking.');
recordblocking(myVoice, 5);
disp('End of recording. Playing back ...');

playerObj = play(myVoice);

disp('Properties of playerObj:');
get(playerObj)

Play back only the first 3 seconds of the speech recorded in the previous example:

play(myVoice, [1 myVoice.SampleRate*3]);