How to detect which audio output device is being used by Windows

18 ビュー (過去 30 日間)
Glenn Kubota
Glenn Kubota 2024 年 3 月 6 日
回答済み: Jimmy Lapierre 2024 年 3 月 13 日
I can detect audio output devices with 'audiodevinfo', but is there a way to tell which of those devices is currently being used by Windows? I want to make sure that Windows is not outputing to the same device that I'm using in my MATLAB script.

回答 (2 件)

Jimmy Lapierre
Jimmy Lapierre 2024 年 3 月 13 日
The best practice for Audio Toolbox users would be to use WASAPI mode (see audioDeviceWriter). It is WASAPI exclusive mode, so that might really what you want. Once you have aquired a device in that mode, no other apps can play on that device.
There might be a way to query the Windows registry for the current default device, but keep in mind that the default device can change at any moment. It is easy to change these days in the task bar by expanding the volume button up. There's also no guarantee that a user hasn't selected a different device in an app like Spotify.

Mario Malic
Mario Malic 2024 年 3 月 6 日
Maybe this will help
devWriter = audioDeviceWriter()
devWriter.getAudioDevices % Gets the available audio devices to output
devWriter.info % Gets the default device that is created by the first line
You can exclude the default device you get from the third line from the devices you get from the second line.
  2 件のコメント
Glenn Kubota
Glenn Kubota 2024 年 3 月 6 日
Well, the second line (devWriter.getAudioDevices) shows me the available devices, but the third line (devWriter.info) always shows a DeviceName of 'Primary Sound Driver' even though I change my WIndows audio output to different devices, so that's not going to work.
Mario Malic
Mario Malic 2024 年 3 月 6 日
Unfortunately, I didn't find something that might work.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by