Is it possible to process two microphones input in real time using DSP System Toolbox(MATLAB)?

跟風遠走 提交于 2019-12-13 06:03:36

问题


I have been trying to implement an Active Noise Cancellation(ANC) system using the Digital System Processing system toolbox. I have used the dsp.AudioRecorder and dsp.AudioPlayer as well. This is my initialization code:

mic_reference = dsp.AudioRecorder('NumChannels',1);
mic_reference.DeviceName='ASIO4ALL v2'; 
mic_error = dsp.AudioRecorder('NumChannels',1);
mic_error.DeviceName='ASIO4ALL v2';
sink1_2 = dsp.AudioPlayer;
sink1_2.DeviceName='ASIO4ALL v2';

where I call step(frame) for each of the microphones. I am getting an error saying that

Error using AudioRecorder/step A given audio device may only be opened once.

Is it the limitation of the DSP system toolbox to be able to operate on only one audio recorder device at a time, or is it possible to use two audio recorder devices at a time?

There is a provision for multichannel processing of the same audio device, but how to process the audio from two independent devices in real time?


回答1:


Charansai,

This is not a limitation of the DSP System Toolbox but the behaviour of the ASIO drivers. ASIO drivers grant exclusive access to an application for playback or recording. So the second object is attempting to re-use the same device for recording and hence the error.

In your case, if your reference signal is channel 1 and error signal is channel 2, you need to record 2 channels of data instead of using two recorder objects.

har = dsp.AudioRecorder('NumChannels', 2);
har.DeviceName = 'ASIO4ALL v2';
hap = dsp.AudioPlayer;
hap.DeviceName = 'ASIO4ALL v2';
data = step(har);
refData = data(:, 1);
errData = data(:, 2);
outData = doSomething(refData, errData);
step(hap, outData);

Hope this helps.

Dinesh




回答2:


When you record your signal, you should be recording it from 2 microphones (each called a channel/observation - i.e left and right channel), and you should combine these two observations together into one stream before passing it to Matlab, you should only pass 1 dual channel signal input into the dsp AudioRecorder toolbox - it does not accept two sources I don't think. When you read in the data, it should be a matrix of 2 vectors (given that you specified 2 channels in the AudioRecorder setup).



来源:https://stackoverflow.com/questions/32842170/is-it-possible-to-process-two-microphones-input-in-real-time-using-dsp-system-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!