How to feed popupmenu with list of audio device
2 views (last 30 days)
Show older comments
Hi all. I want to choose an audio device for dsp.AudioPlayer in GUI from popup menu. When i am using audiodevice command or dspAudioDeviceInfo it gives me names of devices like below
ans =
Podstawowy sterownik przechwytywania dźwięku (Windows DirectSound)
ans =
SoundMAX HD Audio (Windows DirectSound)
ans =
SB Live! 24-bit External (Windows DirectSound)
ans =
The problem is that dsp.AudioPlayer needs DeviceName without the part in the brackets. It needs name like
'SB Live! 24-bit External'
How can I make it?
0 Comments
Answers (1)
Geoff Hayes
on 17 Oct 2014
Zdrapko - you could use strfind to determine where the first open bracket appears in the string, and then remove all that occurs from that index on. Something like
audioDeviceStr = 'SB Live! 24-bit External (Windows DirectSound)';
idx = strfind(audioDeviceStr,'(');
audioDeviceStr = strtrim(audioDeviceStr(1:idx-1));
Running the above will set the string to desired result
audioDeviceStr =
SB Live! 24-bit External
Note that it assumes that your audio device strings have only the one open bracket. If it is just the '(Windows DirectSound)' that you want to remove, then you could do something like
audioDeviceStr = 'SB Live! 24-bit External (Windows DirectSound)';
audioDeviceStr = strtrim(strrep(audioDeviceStr,'(Windows DirectSound)',''));
In the above, we replace the '(Windows DirectSound)' with an empty string.
1 Comment
See Also
Categories
Find more on MATLAB Mobile in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!