Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Songcast Timestamps
07-03-2014, 02:07 PM (This post was last modified: 07-03-2014 02:12 PM by simonc.)
Post: #2
RE: Songcast Timestamps
To calculate latency in a sender:
  • start with a millisecond value
  • multiply by 256
  • multiply by a factor dependent on the clock family in use. (44100 if your audio's sample rate is in the 44.1kHz family; 48000 for the 48kHz family.)
  • divide by 1000
In psuedocode, this becomes
uint CalculateLatency(uint aLatencyMs, uint aSampleRate)
    uint multiplier = ((aSampleRate%441) == 0? 44100 : 48000);
    return ((uint64)aLatencyMs * multiplier * 256) / 1000;

A receiver would reverse this calculation to retrieve a millisecond latency.

Timestamping must only be used if your sender has a very accurate clock. If used, it allows a receiver to detect that it's clock runs at a very slightly different rate to the sender's. If the receiver is capable of varying the rate of its clock, it can adjust to match the sender's speed, avoiding the possibility of eventual audio glitches (either audio starvation if the receiver is faster than the sender or audio buffer overflow if the receiver is slower). This type of small change to clock speed is referred to as clock pulling in some docs.

For best results, the timestamp is applied as close to the network as possible. Linn's DS players use dedicated hardware for this. Songcast app (PC senders) do not supply timestamps; despite using kernel-side software, they still can't access sufficiently accurate clocks. User-side senders should not attempt to provide a timestamp.

I think you have a Java app that runs entirely in user space and primarily targets RaspberryPi? If so, I'd suggest ignoring timestamping. I don't think the RPi is capable of clock pulling. Timestamps applied by a user space sender would be too coarse/unpredictable to help a receiver.
Find all posts by this user

Messages In This Thread
Songcast Timestamps - PeteManchester - 07-03-2014, 10:09 AM
RE: Songcast Timestamps - simonc - 07-03-2014 02:07 PM
RE: Songcast Timestamps - PeteManchester - 07-03-2014, 06:13 PM

Forum Jump: