Main Content

audiodevinfo

Information about audio device

Description

info = audiodevinfo returns information about the input and output audio devices on the system.

example

nDevices = audiodevinfo(IO) returns the number of output devices on the system if IO is 0, and returns the number of input devices on the system if IO is 1.

example

name = audiodevinfo(IO,ID) returns the name of the audio device specified by the device identifier ID.

DriverVersion = audiodevinfo(IO,ID,"DriverVersion") returns the version of the driver for the audio device specified by ID.

support = audiodevinfo(IO,ID,Fs,nBits,nChannels) returns logical 1 (true) if the input or output audio device specified by ID supports the sample rate, number of bits per sample, and number of channels specified by the values of Fs, nBits, and nChannels, respectively, and logical 0 (false) otherwise.

example

devID = audiodevinfo(IO,devName) returns the device identifier of the input or output audio device with name devName. If no device is found with the specified name, then audiodevinfo generates an error.

suppDevID = audiodevinfo(IO,Fs,nBits,nChannels) returns the device identifier of the first input or output device that supports the sample rate, number of bits per sample, and number of channels specified by the values of Fs, nBits, and nChannels, respectively. If no supporting device is found, then suppDevID is -1.

Examples

collapse all

View information about the input and output audio devices on the system by calling audiodevinfo with no inputs. audiodevinfo returns a structure containing two fields, input and output.

info = audiodevinfo
info = struct with fields:
     input: [1×2 struct]
    output: [1×2 struct]

The input field contains audio device names, drivers used, and device identifiers.

info.input
ans=1×2 struct array with fields:
    Name
    DriverVersion
    ID

Display the information about the first input device.

info.input(1)
ans = struct with fields:
             Name: 'Primary Sound Capture Driver (Windows DirectSound)'
    DriverVersion: 'Windows DirectSound'
               ID: 0

Display the information about the second input device.

info.input(2)
ans = struct with fields:
             Name: 'Microphone Array (Microphone Array (Intel® Smart Sound Technology (Intel® SST)) (VDI)) (Windows DirectSound)'
    DriverVersion: 'Windows DirectSound'
               ID: 1

The values on your system might differ from those in this example.

View the number of output audio devices on the system, using an IO value of 0 to indicate output.

nDevices = audiodevinfo(0)
nDevices = 2

The values on your system might differ from those in this example.

Check if the input audio device identified by the ID value 0 supports a sample rate of 44,100 Hz, with 16 bits per sample and two channels.

support = audiodevinfo(1,0,44100,16,2)
support = logical
   1

The result on your system might differ from the one in this example.

Input Arguments

collapse all

Input or output device, specified as 0 to indicate output, or 1 to indicate input.

Audio device identifier, specified as an integer. The device can be an input or output audio device.

Sample rate in hertz (Hz), specified as a positive scalar.

Example: 44100

Data Types: single | double

Bits per sample, specified as a positive scalar.

Example: 16

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Number of audio channels, specified as a positive scalar.

Name of the input or output audio device, specified as a character vector.

Data Types: char

Output Arguments

collapse all

Information about audio devices, returned as a structure array containing the two fields input and 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 structures contain these fields:

  • Name — Name of the device, returned as a character vector.

  • DriverVersion — Version of the driver used to communicate with the device, returned as a character vector.

  • ID — Identifier of the device, returned as a positive integer scalar.

Number of output audio devices (if IO is 0) or number of input audio devices (if IO is 1), returned as a nonnegative integer scalar.

Name of the output audio device (if IO is 0) or input audio device (if IO is 1) with device identifier ID, returned as a character vector.

Driver version of the output audio device (if IO is 0) or input audio device (if IO is 1) with device identifier ID, returned as a character vector.

True or false result, returned as a 1 or 0 of type logical.

support is 1 (true) if the audio device specified by IO and ID supports a sample rate of Fs, with nBits bits per sample and nChannels audio channels. Otherwise, support is 0 (false).

Identifier of the output audio device (if IO is 0) or input audio device (if IO is 1) with device name devName, returned as a positive integer scalar.

Identifier of the first output audio device (if IO is 0) or first input audio device (if IO is 1) that supports a sample rate of Fs, with nBits bits per sample and nChannels audio channels, returned as a positive integer scalar.

Limitations

  • These limitations apply when using audiodevinfo in MATLAB® Online™ or MATLAB Web App Server™:

    • audiodevinfo ignores nBits. For instance, when you call support = audiodevinfo(IO,ID,Fs,nBits,nChannels), audiodevinfo returns a logical 1 if the values of Fs and nChannels match a supported sample rate and number of channels of the audio device. It does not match nBits against the default number of bits per sample of the audio device.

      Similarly, when you call suppDevID = audiodevinfo(IO,Fs,nBits,nChannels), audiodevinfo returns information about an audio device if a supported sample rate and number of channels of the audio device match the values of Fs and nChannels. It does not match nBits against the number of bits per sample supported by the audio device.

    • "DriverVersion" is not supported.

Tips

  • audiodevinfo in MATLAB Online and MATLAB Web App Server is supported in Google Chrome®.

  • Note

    Security Considerations When Using MATLAB Online or MATLAB Web App Server: When using 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 every time it tries to access your microphone, regardless of your browser settings.

Version History

Introduced before R2006a