Information about audio device
returns information about
the input and output audio devices on the system.
info = audiodevinfo
returns the number of input devices on the system if
nDevices = audiodevinfo(
1, and returns the number of output devices on the system if
View Information About Audio Devices
audiodevinfo with no inputs to view information about the input and output audio devices on a system.
audiodevinfo returns a structure containing two fields,
info = audiodevinfo
info = struct with fields: input: [1×2 struct] output: [1×4 struct]
The input field contains audio device names, driver used, and device identifiers.
ans = 1×2 struct array with fields: Name DriverVersion ID
Display the information on the first input device.
ans = struct with fields: Name: 'Primary Sound Capture Driver Windows DirectSound ' DriverVersion: 'Windows DirectSound' ID: 0
Display the information on the second input device.
ans = struct with fields: Name: 'HP 4120 Microphone HP 4120 Windows DirectSound ' DriverVersion: 'Windows DirectSound' ID: 1
The values on your system might differ from this example.
View Number of Output Devices
View the number of output audio devices on the system, using an IO value of 0 to indicate output.
nDevices = audiodevinfo(0)
nDevices = 4
This example shows three output devices, but your system might vary.
Check Support for Input Device
Check if the input audio device identified by the
0, supports a sample rate of
44100 hertz, with
16 bits per sample, and two channels.
support = audiodevinfo(1,0,44100,16,2)
support = logical 1
The input device supports the specified sample rate, number of bits and number of channels. Note that results on your system might vary.
IO — Input or output device
Input or output device, specified as
1 to indicate input, or
0 to indicate output.
ID — Audio device identifier
Audio device identifier, specified as an integer. The device can be an input or output audio device.
Fs — Sample rate
Sample rate, in hertz, specified as a positive scalar.
nBits — Number of bits per sample
Number of bits per sample, specified as a scalar.
nChannels — Number of audio channels
Number of audio channels, specified as
1 (mono) or
name — Name of input or output device
Name of the input or output audio device, specified as a character vector.
info — Information about audio devices
Information about audio devices, returned as a structure array containing two fields,
output. Each field is an array of structures,
with each structure containing information about one of the audio input or output devices on
the system. The individual device structure fields are:
Name— Name of the device, returned as a character vector.
DriverVersion— Name of the driver used to communicate with the device, returned as a character vector.
ID— Device identifier, returned as a scalar.
These limitations apply when using
audiodevinfoin MATLAB® Online™ or MATLAB Web App Server™:
audiodevinfoonly returns information about output audio devices.
The value of
nBitsis ignored. For instance, when you call
support = audiodevinfo(IO,ID,Fs,nBits,nChannels),
audiodevinforeturns a logical
1if the values of
nChannelsthat you specified match the default sample rate and number of channels of the output audio device. It does not match
nBitsagainst the default number of bits per sample of the output device.
Similarly, when you call
ID = audiodevinfo(IO,Fs,nBits,nChannels),
audiodevinforeturns information about an output audio device if the default sample rate and number of channels of the output device match the values of
nChannelsthat you specified. It does not match
nBitsagainst the number of bits per sample that you specified.
'DriverVersion'is not supported.
Security Considerations When Using MATLAB Online or MATLAB Web App Server
audiodevinfo in 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 the MATLAB
Web App Server and run
audiodevinfo, regardless of your browser
Audio playback in MATLAB Online and MATLAB Web App Server are supported in Google Chrome™.