Convert matrix of signal data to sound
Load the example file
which contains sample data
y and rate
and listen to the audio.
load gong.mat; sound(y);
Play an excerpt from Handel's "Hallelujah Chorus" at twice the recorded sample rate.
load handel.mat; sound(y, 2*Fs);
load handel.mat; nBits = 16; sound(y,Fs,nBits);
MATLAB® plays the audio with a bit depth of 16 bits per sample, if this is supported on your system.
y— Audio datacolumn vector |
Audio data, specified as an
vector for single-channel (mono) audio, or an
matrix for stereo playback, where
m is the number
of audio samples. If
y is an
matrix, then the first column corresponds to the left channel, and
the second column corresponds to the right channel. Stereo playback
is available only if your system supports it.
Fs— Sample rate8192 (default) | positive number
Sample rate, in hertz, of audio data
as a positive number between 80 and 1000000.
nBits— Bit depth of sample values8 (default) | 16 | 24
Bit depth of the sample values, specified as an integer. Valid values depend on the audio hardware installed. Most platforms support bit depths of 8 bits or 16 bits.