How to feed popupmenu with list of audio device
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Geoff Hayes
2014년 10월 17일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!