Convert matrix of signal data to sound
Play Audio Data at Default Sample Rate
Load the example file
gong.mat, which contains example data
y and sample rate
Fs, and play the audio.
load gong.mat sound(y)
Play Audio Data at Specified Sample Rate
Play an excerpt from Handel's Hallelujah Chorus at twice the recorded sample rate.
load handel.mat sound(y,2*Fs);
Play Audio Data with Specified Bits per Sample
load handel.mat nBits = 16; sound(y,Fs,nBits)
MATLAB® plays the audio with a bit depth of 16 bits per sample, if this bit depth is supported on your system.
Fs — Sample rate
8192 (default) | positive scalar
Sample rate in hertz (Hz), specified as a positive scalar.
Valid values of the sample rate depend on the audio hardware of your system. Typical sample rates supported by most setups are 8000, 11,025, 22,050, 44,100, 48,000, 96,000, and 192,000 Hz.
In MATLAB® Online™ or MATLAB Web App Server™,
nBits. Instead, it plays audio data using the default number of bits per sample of the output audio device.
soundfunction supports sound devices on all Windows® and most UNIX® platforms.
soundin MATLAB Online and MATLAB Web App Server is supported in Google Chrome®.
Security Considerations When Using MATLAB Online or MATLAB Web App Server: When using
soundin MATLAB Online or MATLAB Web App Server, certain features and settings help you keep control of your privacy.
To reduce the likelihood of unwanted applications using your microphone, turn off automatic access to your audio device. You can change these settings at any time. After granting permission to a website once, your browser may be able to access your microphone automatically for that site on future visits. Use the browser settings for Google Chrome to revoke access for specific sites after you have initially allowed access.
You can also access the MATLAB Online website or MATLAB Web App Server using the private browsing mode in Google Chrome. When you do this, Chrome® automatically asks you for permission to access your microphone every time you open the MATLAB Online site or MATLAB Web App Server and run
sound, regardless of your browser settings.
Introduced before R2006a