0

I am working on a project where a server parses audio files, and then tells clients to play certain sections of audio based on a common clock, the server's. In theory we would need a high level of synchronization as the client nodes might be playing audio right beside each other, and all but the smallest of delays may produce a sound offset noticeable by the human ear. I have been trying to find c code examples of how to address this problem and have had little luck.

I have read many of the Wikipedia articles about clock synchronization.

http://en.wikipedia.org/wiki/Clock_synchronization

The above articles lead me to believe PTP would be ideal for our implementation on a local network. But ideally we would like to expand our project to allow for connection over the internet. This lead me to believe NTP would be better. I visited NTP.org but found it difficult to understand, and it seemed like if my applications are on a local network, which isn't connected to the internet, I couldn't use NTP at all. But then I found this post:

Small footprint clock synchronization without NTP

And Seth Robertson's response lead me to believe I was mistaken.

you can get synchronized to a chosen system's clock using a few configuration file lines (four lines on each client, five lines on the server).

The problem is, he didn't show those lines of code, or point me to a place where I could view code that handles these problems.

I've been looking around stackoverflow, and found many similar questions, but none that gave satisfactory answers.

So, after a wall of text (sorry about that, the stack overflow question advice said to be very specific and explain the research I had done before asking a question), I would like to succinctly state my question, and hopefully someone can help me out:

In a client/server software model, how can I maintain an accurate clock synchronization within the software to allow event execution based on time?

Currently our group is using UDP, but we are willing to change if necessary.

Thanks for any help.

EDIT: I understand that I need to maintain a clock sync, the question is, HOW do I do this in software. I'm looking for example code, or a hyperlink to a place where I can find sample code on this subject. ENDEDIT

Community
  • 1
  • 1
  • 1
    NTP is packaged for most operating system, and it's usually just a matter of starting the server (and installing it if you're on an OS where it's not alreadt installed) However, do you really need time to sync this ? Doesn't the position in the audio give you a reference time, i.e. your server figures out that at this time , the stream should be played at a certain byte offset, and you hand that offset off to the clients – nos Nov 21 '12 at 21:54
  • I don't think ntp is what you are looking for. Looks like the JACK Audio Connection Kit will be better suited. – ninjalj Nov 21 '12 at 22:29

1 Answers1

0

The concept is clear: Select one host in your network to be the NTP server, and let the other hosts synchronise themselfs with this server.

If your need is just synchronisation between the hosts of your LAN this should do.

NTP servers as well as clients are freely available for a lot of systems.

alk
  • 69,737
  • 10
  • 105
  • 255
  • _Select one host in your network to be the NTP server, and let the other hosts synchronise themselfs with this server._ Yes, this is exactly what I want to do. HOW do I do it? – Jevin Anderson Nov 24 '12 at 17:59
  • Which OS are your servers using? @user1843252 – alk Nov 24 '12 at 21:25
  • The server is using Linux Redhat. – Jevin Anderson Nov 25 '12 at 20:13
  • The NTP home gives plenty of infos at: http://www.ntp.org/ntpfaq/ Also I'm not a Red Hat admin. A quick google for "howto ntp redhat" discoverd this for example http://www.halley.cc/ed/linux/howto/ntp.html and plenty of other pages dealing with the setup of an NTP server. @user1843252 – alk Nov 26 '12 at 09:56