I have read several topics on this issue, but the ones I have found differed from mine slightly.
I wish to record 2 sound recordings at once. I have both mic's plugged in. I set up two audiorecorder functions like this:
rec1=audiorecorder(44100,8,1,1);
rec2=audiorecorder(44100,8,1,2);
record(rec1,3);
record(rec2,3);
Only rec1 recorded. I can see this by plotting the audiodata for both recordings. Is this problem due to MatLab not recognizing the 2nd microphone? Or is there something inherently wrong with my code?
Also, would there be an easier way to do multiple recordings? I've read something about Data Acquisition Toolbox, but I don't have it and have never used it.
Thanks for your help.
No products are associated with this question.
8 Comments
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_112089
Is audiodevinfo() showing the devices as being connected on those ID's?
If you exchange the mic's, does the problem stay with the mic or with the ID ?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113631
I think they are at 0,1. Here is the data I am getting:
>> rec1
rec1 =
Properties: SampleRate: 44100 BitsPerSample: 8 NumberOfChannels: 1 DeviceID: 1 CurrentSample: 1 TotalSamples: 132300 Running: 'off' StartFcn: [] StopFcn: [] TimerFcn: [] TimerPeriod: 0.050000000000000 Tag: '' UserData: [] Type: 'audiorecorder'>> rec2
rec2 =
Properties: SampleRate: 44100 BitsPerSample: 8 NumberOfChannels: 1 DeviceID: 2 CurrentSample: 1 TotalSamples: 132300 Running: 'off' StartFcn: [] StopFcn: [] TimerFcn: [] TimerPeriod: 0.050000000000000 Tag: '' UserData: [] Type: 'audiorecorder'>> audiodevinfo(0)
ans =
>> audiodevinfo(1)
ans =
>>
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113635
When I do this code:
det 1 has the expected values and det 2 has nothing...it is all 0s
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113640
In a session, before using audiorecorder(), please see what
return
I am concerned about the possibility that audiorecorder() sets up control structures but does not test whether the device is present; knowing that audiodevinfo() believes the devices to be at 1 and 2 would be helpful.
Also, does the problem stay with the microphone or with the device number if you exchange the microphones ?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113655
audiodevinfo(0,1) audiodevinfo(0,2)
These both give me error messages saying
"device ID out of range"
However,
audiodevinfo(1,2)
says:
Rear Input (SoundMAX Integrated Digital High Definition Audio) (Windows DirectSound)
audiodevinfo(1,1)
says:
Microphone (USB Audio Device) (Windows DirectSound)
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113656
When the device numbers were swapped, the microphone that recorded swapped as well.
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_113662
Ah, I misread about input vs output. 1 instead of 0 it is.
Your system has 5 logical audio input devices. The first of them is a USB microphone. The second of them is an stereo jack style on your laptop. I do not have enough information at present to know where the other 3 logical input devices are.
Which microphone inputs do you think you are using? For example if you are using two USB microphones, then you need to find the device ID that corresponds to that USB microphone.
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54191#comment_114172
I found out why Matlab wasn't recording with one of them, and it was because there was a faulty USB port that it was plugged in to-I tried plugging a mouse into it and that didn't work either. When I plugged it into a different USB, I got this for the audiodevinfo, and it seems to work fine:
>> audiodevinfo(1,1)
ans =
Microphone (1- USB Audio Device) (Windows DirectSound)
>> audiodevinfo(1,2)
ans =
Microphone (2- USB Audio Device) (Windows DirectSound)