Is sampling rate 384kHz through direct sound playable in MATLAB?

조회 수: 6 (최근 30일)
哲史 伊藤
哲史 伊藤 2023년 5월 10일
답변: Govind KM 2024년 9월 20일
I am trying to produce ultrasound through a directsound soundcard (radius RK-DA60C), which supports 384kHz sampling rate.
Using other softwares like Audacity, I confirmed with an oscilloscope that 120kHz sine wave is playable.
However, it is not successful in MATLAB.
First, I used Data Acquisiion Toolbox and it reported an error "Rate cannot exceed 192000 in the current configuration."
Next, I used audioplayer function in MATLAB like,
a=rand(192000,1)-0.5;
pl=audioplayer(a,384000,16,6) % Device ID is 6
play(pl)
and got "Device Error: Unanticipated host error"
When I reduce the sampling rate,
pl=audioplayer(a,192000,16,6)
Player worked correctly.
Does anyone know whether the 384kHz sampling rate is supported or not?

답변 (1개)

Govind KM
Govind KM 2024년 9월 20일
Audio features from base MATLAB, such as “audioplayer”, use the “DirectSound” audio host which is limited to 192kHz. This causes the mentioned “Unanticipated Host” error.
A workaround for this is to set the driver to “WASAPI” or “ASIO” using “audioDeviceWriter”, as these drivers do not limit the sample rate to 192kHz. This requires a license for the Audio Toolbox.
Sample code to set the driver to “WASAPI” is given below:
%Set driver as WASAPI or ASIO
adw=audioDeviceWriter("Driver","WASAPI","SampleRate",384e3);
%Using pinknoise as sample audio
adw(pinknoise(1024*16,2));
To get the name of your output device to pass as argument, the “getAudioDevices” function can be used to list available devices for the selected driver:
getAudioDevices(adw);
More details on “audioDeviceWriter” and “getAudioDevices” can be found in the documentation below:
Hope this is helpful!

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by