I have a better idea of the time

In a previous post, I talked about getting accurate time syncs between Android phones. My main objective has been to learn Android app development and I’ve found the best approach for me (for everyone?) is to implement a project. A SMPTE timecode generator is what I chose.


To develop a mobile app, you have to get confortable with things like:

  • creating a GUI layout based on XML and learning the available controls.
  • understand the main event loop related mechanisms, Activity, in the case of Android.
  • know how to change colors, fonts and sizes
  • how to use icons. The android ecosystem has many icons available but then you have to copy several image files for each icon you want to use to account for the different sized devices.
  • you have to be cognizant of when different system APIs were introduced. I want my app to be runnable on old phones 1

To talk a bit about my SMPTE app, I am almost comfortable with my ability to sync between phones. I considered something like syncing using some sort of audio signal. One master phone could emit a series of blips and the slave phone could emit its own blips and listen to the combination of the two. As suggested like my friend Vanya, I could treat it like a PLL. The child phone would look at the sound it’s hearing and move its own signal forward or backward. I will probably try this as well but I haven’t yet played with Android audio stuff.

The approach I’ve taken so far is to use a socket connection between phones. The slave phone sends a kind of ping to the master which responds with its current time value. If the slave does 10 of these in quick succession, one of them is usually within 10ms round trip. I figure/hope that anyone wanting to use an app like mine would have an old wifi router laying around.

The display gives the date and time followed by a hundredth counter. So in this picture the four devices are within 5/100 sec or 50ms.


And here’s another with lucky timing. 2/100 sec.


I imagine that some/much of the the differences are due to timing accuracy of the Android system. Updating the display a kind of round about. I have a scheduling thread that calls by callback every 10ms. That callback decides what to display and sends that along to the main UI thread.

SMPTE timecode is only as fast as 30 frames per second, so 5ms or 10ms deviation is probably fine.

I’m curious to see how/whether things change with the audio output. In that case, I don’t need a timer. I will simply feed numbers into an audio buffer and add more as the buffer empties. Is it harder to get consistency with audio or display timing?

  1. I really like the idea of finding new uses for old phones we’ve just thrown in a drawer somewhere

Leave a Reply

Your email address will not be published. Required fields are marked *