How to record in to matlab using two microphones simultaneously?

  • MATLAB
  • Thread starter sudevschiz
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses a project to create a sound source locator using two microphones and MATLAB. The person has encountered problems with using internet time synchronization for recording and is seeking solutions. The conversation also touches on the possibility of using a microcontroller or a LAN cable for more accuracy and the suggestion of using a common sync signal for stereo recording. They also mention a real-time OS and IEEE Standard 1588 for accurate syncing over networks. Finally, there is a suggestion to use a pulse from a child's toy clicker to adjust for variable delays in sound sources.
  • #1
sudevschiz
2
0
I’m working on a project to make a sound source locator. My theory is to detect the sound using two microphone located at a known distance and find out the time delay to make out the direction of the sound.
I am using MATLAB to take input from the microphone.
To take input from two microphones, I used two laptops.
I need the recording to start automatically, so I used Internet time synchronisation in both the laptops and then wrote a code in MATLAB to start the recording at a specified time.
But the problem is that, the internet time synch is not accurate enough. I need something like millisecond precision.
That’s not happening with internet time synch.
Any solutions to any part of the problem?
 
Physics news on Phys.org
  • #2
sudevschiz said:
I’m working on a project to make a sound source locator. My theory is to detect the sound using two microphone located at a known distance and find out the time delay to make out the direction of the sound.
I am using MATLAB to take input from the microphone.
To take input from two microphones, I used two laptops.
I need the recording to start automatically, so I used Internet time synchronisation in both the laptops and then wrote a code in MATLAB to start the recording at a specified time.
But the problem is that, the internet time synch is not accurate enough. I need something like millisecond precision.
That’s not happening with internet time synch.
Any solutions to any part of the problem?

Hey sudevschiz and welcome to the forums.

The one thing I can recommend is to check what network protocol you are using and also don't use the internet if you don't have to: use a LAN cable and connect it directly to both computers (you will need to use a special LAN cable and not the same one you use for connecting to a router for example).

So use a LAN cable and look into something like UDP over the reliable TCP/IP if you need more speed since the LAN will provide a high degree of reliability which means UDP should be good to use.
 
  • #3
A regular PC running windows won't be accurate to better than a few ms at best (1 ms if you are lucky). If you need to sync to 1 ms you need a real-time OS, OR a hardware solution of some sort. There are professional solutions for "distributed" recording but they are very expensive.

This would be an easy problem to solve if the computers can be connected to cables (just record a common sync signal and use that to sync the signals in post-processing)?
If not, you need some sort of external hardware..
 
  • #4
I found somewhere in the internet that it's possible to make another laptop in a network with the time of my laptop by announcing myself as the time server.

Anybody has any idea about that?

Or should I think about jumping into the next step and working with a micro controller which can take multiple inputs from two microphone?

Do you think a micro controller can provide me the accuracy required?
If yes, which one?

Is it a good idea to move on to the hardware level without confirming the theory I have?
 
Last edited:
  • #5
You need to figure out exactly what you want to do.

Using a microcontroller would be difficult, and it would not necessarily solve the main problem which is that it is difficult (but not impossible) to accurately sync over a standard network.
You might as well just install a real-time OS on your two laptops.

There are already frameworks for accurate syncing over networks, in particular IEEE Standard 1588 which -I believe- should let you sync two events with microsecond accuracy if you use real-time targets and an external 1MHz oscillator as a reference (at least this is what Labview claims to be able to do which uses said framework).

But again, this would be an easy problem to solve if you could just connect your two laptops using a cable ( a standard coax-cable would on). Then you could just use a common sync signal (which could even be generated by the soundcard on one of the laptops). You could then do a stereo-recording, with the mic connected to e.g. the left channel and the sync signal to the right.
Aligning the signals in post-processing would be easy.
 
  • #6
I used to work at Autec in the Bahamas and we used hydrophones all over TOTO, on the bottom in patterns and hanging vertically. They picked up pings from torpedo's and such and the old computers of the day had no trouble tracking them in real time, well real time minus the time of flight of the sound but all the signals of all those hydrophones were digitized and sent over microwave to the main site where a computer with all the power of a commodore 64 generated 3D information as to the location of the torpedo being tracked and then plotted on 3 separate plot boards, XY in one, like looking down at the top of a fishtank, then XZ, like looking at one side and YZ looking at the other side, you could figure out just where the torpedo was very quickly.

I imagine things have gotten a whole lot faster now with modern computers and such and probably much higher bandwidth links, maybe even fiber optic by now.

Why can't you have a variable delay in one sound track and carefully adjust that to sync sound sources? For instance, you can use one of those child's toy clickers to send out a pulse that would bounce off walls and such and one click propagation would arrive at a mic before the other depending on where the mics were placed. Send me an email to dnphoton@ptd.net as I have a similar project but with different aims, maybe we could help each other. Name here is Don.
 

Related to How to record in to matlab using two microphones simultaneously?

1. How do I connect two microphones to my computer for recording in MATLAB?

To connect two microphones to your computer, you will need a USB audio interface with at least two inputs. Plug in the microphones to the inputs on the interface and connect the interface to your computer via USB.

2. Can I record in stereo using two microphones in MATLAB?

Yes, you can record in stereo by selecting both microphones as input devices in MATLAB. Make sure to set the recording mode to stereo in the audio settings.

3. What is the best way to synchronize the recordings from two microphones in MATLAB?

You can use a synchronization signal, such as a clap or a beep, at the beginning of your recording to align the two recordings in MATLAB. You can also use external hardware to synchronize the two microphones.

4. How can I adjust the volume levels of the two microphones when recording in MATLAB?

You can adjust the volume levels of each microphone by using the audio settings in MATLAB. You can also use an external mixing console or audio interface to adjust the levels before recording.

5. Is it possible to record in real-time with two microphones simultaneously in MATLAB?

Yes, it is possible to record in real-time with two microphones simultaneously in MATLAB. However, this may require a powerful computer and a low-latency audio interface to ensure smooth recording without any delays.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top