我想在Matlab(2012a)中同时获取多个USB麦克风。但是,两个录音功能都是短腿的。
1,recordblocking()
- 它允许用户指定录制的持续时间,但每个麦克风必须按顺序录制。所以我不知道如何让它同时录音。
2,record()
- 它允许用户同时记录多个信号,但它只运行1秒钟(大致)。
我使用的代码如下:
recObj1 = audiorecorder(44100, 16, 1, 1);
recObj2 = audiorecorder(44100, 16, 1, 3);
disp('Start speaking.')
% recordblocking(recObj1, n);
% recordblocking(recObj2, n);
disp('Real recording.')
% by the way, the following function doesn't take 'on' as the second argument as opposed to what the internal/external documentation says
record(recObj1, 1);
record(recObj2, 1);
disp('End of Recording.');
基本上,我无法同时录制多个麦克风输入n秒。请帮忙。
答案 0 :(得分:0)
您显然阅读了此文档,该文档涉及从端口记录数据:http://www.mathworks.de/de/help/matlab/ref/record.html
这是audiorecorder的录音功能: http://www.mathworks.de/de/help/matlab/ref/audiorecorder.record.html
第二个输入参数是持续时间。
答案 1 :(得分:0)
试试这个:
%records from speaker IDs 0 (probably internal microphone) & 3,
%using audiorecorder function.
recobj1 = audiorecorder(22500,16,2,0);
recobj2 = audiorecorder(22500,16,2,3);
disp('start speaking.')
record(recobj1,5);
record(recobj2,5);
recordblocking(recobj1,5);
%recordblocking(recobj3,2);
disp('end of recording');
y1 = getaudiodata(recobj1);
wavwrite(y1,22500,16,'recobj1');
y2 = getaudiodata(recobj2);
wavwrite(y2,22500,16,'recobj2');
plot(y1)
plot(y2)
它还会绘制结果。放大以查看两个麦克风输出之间的差异。