Digital Signal Processing Reference
In-Depth Information
audiorecorder objects like sound or wavplay did with the data in previous examples.
Leaving the semicolon o the end of the play command shows information about
the object.
x_object = audiorecorder(44100, 8, 1);
record(x_object, 2);
pause(2.2);
play(x_object)
Though we may desire to record at a lower sampling rate, it may not be sup-
ported. The author found that calling the record function for an audioplayer ob-
ject of 8000 samples/second resulted in a warning message about \unsupported
audio format," while a similar call to function recordblocking failed to return!
The dierence between the two calls should simply be when the control returns to
the user; record returns right away (continuing work in the background), while
recordblocking returns after the recording time elapses.
Can we use the sound function with the audioplayer object? Yes, though we
must rst get the data in a format that the sound function can use. In other words,
we want the raw sound data, not the nice object encapsulation. The getaudiodata
function provides such a facility, as seen below.
% convert the data to an array of doubles
x = getaudiodata(x_object, double);
% play it back
sound(x, 44100);
In summary, of the commands used in this section, we saw that wavrecord and
wavplay are not supported on all platforms. To get around this incompatibility,
other software (besides MATLAB) can be used to record sound, and the sound
command can be used in place of wavplay. The audiorecorder command, and
related functions, also allow the user to work with sound. These commands are
worth exploring, though they are not implemented in older MATLAB versions.
10.2
Examples Working with Images
Working with images can be rewarding. The results are readily apparent, in a
concrete way. MATLAB provides functions to make image processing very easy.
The examples in this section are meant to give the reader a quick understanding of
what MATLAB can do.
The code below draws a small, white rectangle on a black background. The
imwrite command below saves the image to disk, in the TIFF format.
Search WWH ::




Custom Search