How to record in to matlab using two microphones simultaneously?

  • Context: MATLAB 
  • Thread starter Thread starter sudevschiz
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around the challenges of recording audio from two microphones simultaneously using MATLAB for a sound source localization project. Participants explore issues related to synchronization accuracy, potential hardware solutions, and alternative methods for achieving precise timing.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes the need for millisecond precision in recording synchronization, expressing dissatisfaction with internet time synchronization.
  • Another suggests using a direct LAN connection instead of the internet to improve synchronization reliability, recommending UDP over TCP/IP for speed.
  • A different participant mentions that achieving synchronization better than a few milliseconds typically requires a real-time operating system or specialized hardware solutions.
  • One post raises the possibility of setting up a laptop as a time server within a network to improve synchronization accuracy.
  • Another participant questions whether transitioning to a microcontroller for handling multiple microphone inputs would provide the necessary accuracy, while also considering the implications of moving to hardware without confirming the underlying theory.
  • One contributor discusses the potential of using IEEE Standard 1588 for precise synchronization, suggesting that a common sync signal could simplify the process if the laptops were connected via cable.
  • A participant shares an anecdote about using hydrophones for tracking in real-time, proposing the idea of introducing a variable delay in one audio track to synchronize sound sources based on their physical placement.

Areas of Agreement / Disagreement

Participants express differing opinions on the best approach to achieve synchronization, with no consensus on whether to pursue software solutions, hardware solutions, or a combination of both. The discussion remains unresolved regarding the most effective method for achieving the desired precision.

Contextual Notes

Participants highlight limitations related to standard network synchronization methods and the potential need for specialized equipment or configurations to achieve the required accuracy.

sudevschiz
Messages
2
Reaction score
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
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.
 
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..
 
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:
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.
 
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
4
Views
3K