Hi Tom,
My plan was to use the absolute time to stamp each sample, but it is also
necessary for me to match the exact timing of events occurring elsewhere with
the signal as it is processed in real-time, i.e. I need to be confident that event driven time stamps taken elsewhere (an experiment running on a separate thread) are in step with the generated sample time stamps.
Anyway, I've tested a variety of different acquisitions over 60s, and a couple over 30s and 120s, and I observed the difference between the final absolute and final relative time stamps in each case. I've tried varying the following in various combinations:
- Sampling frequency (several values between 1 and 100 kHz)
- Number of channels being sampled (1,2 & 4)
- Buffer read frequency (0.005 s and 0.05 s)
The result I get is consistent across all these conditions. Every 60s the absolute time stamp outpaces the relative time stamp by roughly 2ms.
Thinking that the problem might be with gettimeofday, I tried using a different time function (one in the Mac OS X CoreAudio framework with nanosecond accuracy), and it also reported a 2ms per 60s discrepancy.
The only thing I am able to conclude from this is that either the card is sampling too quickly or the system clock is moving too slowly, but 2ms per 60s seems an awfully large difference.
Any suggestions would be very welcome!
Kind regards,
Jonathan