23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Audio and Video Data<br />

Importing Audio/Video Data<br />

<strong>MATLAB</strong> includes several functions that you can use to bring audio or video<br />

data into the <strong>MATLAB</strong> workspace. Some of these functions read audio or<br />

video data from files. Another way to import audio data into the <strong>MATLAB</strong><br />

workspace is to record it using an audio input device, such as a microphone.<br />

The following sections describe<br />

• “Reading Audio and Video Data from a File” on page 6-93<br />

• “Recording Audio Data” on page 6-93<br />

Reading Audio and Video Data from a File<br />

<strong>MATLAB</strong> includes several functions for reading audio or video data from a<br />

file. These files are format-specific.<br />

• auread —Returns sound data from a sound (AU) file<br />

• aviread —Returns AVI data as a <strong>MATLAB</strong> movie<br />

• wavread —Returns sound data from a sound (WAV) file<br />

Recording Audio Data<br />

To bring sound data into the <strong>MATLAB</strong> workspace by recording it from an<br />

audio input device, use the audio recorder object. This object represents<br />

the connection between <strong>MATLAB</strong> and an audio input device, such as a<br />

microphone, that is connected to your system. You use the audiorecorder<br />

function to create this object and then use methods and properties of the<br />

object to record the audio data.<br />

On PCs running Windows,youcanalsousethewavrecord function to bring<br />

live audio data in WAV format into the <strong>MATLAB</strong> workspace.<br />

Once you import audio data, <strong>MATLAB</strong> supports several ways to listen to the<br />

data. You can use an audio player object to play the audio data. Use the<br />

audioplayer function to create an audio player object.<br />

You can also use the sound or soundsc function.<br />

On PCs running Windows, you can use the wavplay function to listen to .wav<br />

files.<br />

6-93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!