getAudioDevices

List available audio devices

Description

example

devices = getAudioDevices(obj) returns a list of audio devices that are available and compatible with your audio I/O object, obj.

Examples

collapse all

Create an audioDeviceReader object and then call getAudioDevices on your object.

deviceReader = audioDeviceReader;
devices = getAudioDevices(deviceReader)
devices = 1×4 cell array
    {'Default'}    {'Primary Sound Capture Driver'}    {'Headset Microphone (Plantronics C325-M)'}    {'HP 4120 Microphone (2- HP 4120)'}

Create an audioDeviceWriter object, and then call getAudioDevices on your object.

deviceWriter = audioDeviceWriter;
devices = getAudioDevices(deviceWriter)
devices = 1×6 cell array
    {'Default'}    {'Primary Sound Driver'}    {'Headset Earphone (Plantronics C325-M)'}    {'LEN LT2452pwC (NVIDIA High Definition Audio)'}    {'Speakers (Realtek High Definition Audio)'}    {'HP 4120 (2- HP 4120)'}

Create an audioPlayerRecorder object, and then call getAudioDevices on your object.

playRec = audioPlayerRecorder;
devices = getAudioDevices(playRec)
devices = 1×2 cell array
    {'Default'}    {'ASIO4ALL v2'}

Input Arguments

collapse all

Audio I/O object, specified as an object of audioDeviceReader, audioDeviceWriter, or audioPlayerRecorder.

Data Types: object

Output Arguments

collapse all

List of available and compatible devices.

For audioDeviceReader and audioDeviceWriter, the list of audio devices depends on the specified Driver property of your object.

For audioPlayerRecorder, the audio devices listed support full-duplex mode and have a platform-appropriate driver:

  • Windows® –– ASIO™

  • Mac –– CoreAudio

  • Linux® –– ALSA

Data Types: cell

Tips

Devices are persistent within a MATLAB® session. To recognize new devices within your MATLAB session, clear device data within your session using the command line. As an example, if you have created an audioDeviceReader System object™, you can type the following into your command line:

>> deviceReader = audioDeviceReader;
>> devices = getAudioDevices(deviceReader)
devices =

  1×1 cell array

    {'No audio input device detected'}

This displays a list of the devices connected to your computer. To add more devices, connect the additional devices to your computer. Then, type the following into your command line:

>> clear deviceReader dspAudioDeviceInfo
>> deviceReader = audioDeviceReader;
>> devices = getAudioDevices(deviceReader)
devices =

  1×3 cell array

    {'Default'}    {'Primary Sound Capture Driver'}    {'Headset Microphone (Plantro…'}

This displays an updated list of the devices connected to your computer, including the devices you added during your current session. This process also works with the audioDeviceWriter and audioPlayerRecorder System objects.

Introduced in R2016a