Skip to Main Content Skip to Search
Product Documentation

sound - Convert matrix of signal data to sound

Syntax

sound(y,Fs)
sound(y,Fs,bits)

Description

sound(y,Fs) sends audio signal y to the speaker at sample rate Fs. If you do not specify a sample rate, sound plays at 8192 Hz. For single-channel (mono) audio, y is an m-by-1 column vector, where m is the number of audio samples. If your system supports stereo playback, y can be an m-by-2 matrix, where the first column corresponds to the left channel, and the second column corresponds to the right channel. The sound function assumes that y contains floating-point numbers between -1 and 1, and clips values outside that range.

sound(y,Fs,bits) specifies the bit depth (that is, the precision) of the sample values. The possible values for bit depth depend on the audio hardware available on your system. Most platforms support depths of 8 bits or 16 bits. If you do not specify bits, the sound function plays at an 8-bit depth.

Tips

Examples

Load the demo file gong.mat, which contains sample data y and rate Fs, and listen to the audio:

load gong.mat;
sound(y, Fs);
 

Play an excerpt from Handel's "Hallelujah Chorus" at twice the recorded sample rate:

load handel.mat;
sound(y, 2*Fs);

See Also

audioplayer | soundsc | wavread | wavwrite

How To

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS