Clear Filters
Clear Filters

Interface microphones using matlab

14 views (last 30 days)
I have three microphones and i want to record the signals from the microphones simultaneously, is it possible in matlab?
i used the below mentioned program and i can acquire data from one microphone but im not able to get from all the three at the same time
clear all
close all
clc
AI = analoginput('winsound');
addchannel(AI, 1);
Fs = 8000;
set (AI, 'SampleRate', Fs)
duration = 20;
set(AI, 'SamplesPerTrigger', duration*Fs);
start(AI);
data = getdata(AI);
delete(AI)
  10 Comments
RAJKUMAR Palaniappan
RAJKUMAR Palaniappan on 20 Apr 2012
I think the data which comes into the matlab workspace is only from the default device,
RAJKUMAR Palaniappan
RAJKUMAR Palaniappan on 20 Apr 2012
i used the following code but still not able to interface
AI = analoginput('winsound',0);
AI1 = analoginput('winsound',1);
addchannel(AI,1);
addchannel(AI1,1);
Fs = 8000;
set (AI, 'SampleRate', Fs)
set (AI1, 'SampleRate', Fs)
duration = 20;
set(AI1, 'SamplesPerTrigger', duration*Fs);
set(AI, 'SamplesPerTrigger', duration*Fs);
start(AI1);
start(AI);
data = getdata(AI,AI1);
plot(data,'DisplayName','data','YDataSource','data');figure(gcf)
delete(AI1)
delete(AI)

Sign in to comment.

Accepted Answer

Geoff
Geoff on 20 Apr 2012
Sorry mate, it looks like you are expecting the two-channel mic jack on your sound card to have three inputs.
Go and buy yourself a USB sound interface with 4 mic preamps.
The Alesis iO4 or Tascam US-600 are among the cheapest devices out there. Bonus is they will take a 5mm jack on all channels, since I assume you are not using professional microphones.
As for using only two microphones on one sound card, yes you should be able to do this. But you need to make a stereo splitter cable (or there may be something at your local electronics shop) which turns a single male stereo 3.5mm male jack into two mono 3.5mm female sockets (corresponding to left and right).
Plug that into your computer, and a mic into each of the sockets on the splitter. Then you should be able to at least record two mono channels (assuming that the mic input is stereo). You will, however, not have individual gain control on the two mics.
If you really do have more than one device, then you should be able to choose that device with your initial call to analoginput:
doc analoginput
It might not be 'winsound', and if it is, try the second parameter which selects the hardware ID.
Also, if you are using 64-bit MatLab, you need to read the documentation, which states that you can't use the analoginput interface.
  5 Comments
Walter Roberson
Walter Roberson on 29 Apr 2012
If you have a multi-channel NI DAQ, then Yes, the inputs could be synchronized.
Walter Roberson
Walter Roberson on 26 Feb 2020
Over the years I came across the fact that the standard Windows drivers for audio are two channels at most, so even if you could get a third channel in physically, that the drivers would not deal with it. The workaround involved using ASIO drivers (I am sure of this), and I cannot quite recall for sure whether using PortAudio drivers would work but I think so. Or use the data acquisition toolbox to talk to a multichannel A/D card.

Sign in to comment.

More Answers (1)

Goz Qht
Goz Qht on 26 Feb 2020
clear all close all clc AI = analoginput('winsound'); addchannel(AI, 1); Fs = 8000; set (AI, 'SampleRate', Fs) duration = 20; set(AI, 'SamplesPerTrigger', duration*Fs); start(AI); data = getdata(AI); delete(AI)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!