Error in 'untitled/Audio Device Writer': A given audio device may only be opened once.
28 次查看(过去 30 天)
显示 更早的评论
why do i get this error >>> Error in 'untitled/Audio Device Writer': A given audio device may only be opened once<<< while rinning my simlunk block that play a sound?
note that i run it before with no problems. however, now i got this error although i didn't put any changes!!!
0 个评论
采纳的回答
Gabriele Bunkheila
2018-11-29
Hi Fatima,
You may have multiple block instances pointing to the same device in your model, another Simulink model running, or you may similarly have run or created instances of audioDeviceWriter in your MATLAB session. Checking other models open, other blocks in your model, or clearing (or even releasing) existing competing object instances in MATLAB should solve this.
Thanks,
Gabriele.
更多回答(1 个)
Gabriele Bunkheila
2018-12-3
编辑:Gabriele Bunkheila
2018-12-3
Hi Fatima,
Please refer to the code in the example "Audio Stream from Device to Device" under " Quick Start Examples" in the page Real-Time Audio in MATLAB. In particular, the few lines of code below should do what you need:
% In the two lines of code below, provide any additional property value necessary to point the object to your sound card(s)
deviceReader = audioDeviceReader;
deviceWriter = audioDeviceWriter('SampleRate',deviceReader.SampleRate);
disp('Begin Signal Input...')
tic
while toc < 5
mySignal = deviceReader();
% Process mySignal as needed
deviceWriter(mySignal);
end
disp('End Signal Input')
release(deviceReader)
release(deviceWriter)
Regards,
Gabriele.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!