Is it possible to process two microphones input in

2019-09-02 02:09发布

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?

2条回答
我只想做你的唯一
2楼-- · 2019-09-02 02:53

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).

查看更多
老娘就宠你
3楼-- · 2019-09-02 02:57

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

查看更多
登录 后发表回答