wavplay

Play recorded sound on PC-based audio output device

Syntax

wavplay(y,Fs)
wavplay(...,'mode')

Description

wavplay(y,Fs) plays the audio signal stored in the vector y on a PC-based audio output device. You specify the audio signal sampling rate with the integer Fs in samples per second. The default value for Fs is 11025 Hz (samples per second). wavplay supports only 1- or 2-channel (mono or stereo) audio signals.

wavplay(...,'mode') specifies how wavplay interacts with the command line, according to the string 'mode'. The string 'mode' can be

The audio signal y can be one of four data types. The number of bits used to quantize and play back each sample depends on the data type.

Data Types for wavplay

Data Type

Quantization

Double-precision (default value)

16 bits/sample

Single-precision

16 bits/sample

16-bit signed integer

16 bits/sample

8-bit unsigned integer

8 bits/sample

Remarks

You can play your signal in stereo if y is a two-column matrix.

Examples

The MAT-files gong.mat and chirp.mat both contain an audio signal y and a sampling frequency Fs. Load and play the gong and the chirp audio signals. Change the names of these signals in between load commands and play them sequentially using the 'sync' option for wavplay.

load chirp;
y1 = y; Fs1 = Fs;
load gong;
wavplay(y1,Fs1,'sync') % The chirp signal finishes before the 
wavplay(y,Fs)          % gong signal begins playing.


© 1984-2008 The MathWorks, Inc.