Tuesday, May 15, 2012

play sound with matlab

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 The sound function supports sound devices on all Windows and most UNIX platforms. Most sound cards support sample rates between 5 kHz and 48 kHz. Specifying a sample rate outside this range produces unexpected results. 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);

0 comments:

Post a Comment