# Two Clock Drift Compensation, howto?

**URL:** <https://www.ruby-forum.com/t/two-clock-drift-compensation-howto/241450>\
**Category:** GNU Radio\
**Created:** [April 7, 2015, 4:36pm UTC](https://www.ruby-forum.com/t/two-clock-drift-compensation-howto/241450 "2015-04-07T16:36:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 7, 2015, 4:36pm UTC](https://www.ruby-forum.com/t/two-clock-drift-compensation-howto/241450/1 "2015-04-07T16:36:35Z")

</div>

Dear all!

When I have multiple hw audio (or other) sources and sinks gnuradio is  
suffering from the “two clock problem”.

From the docs I have read, one means to mitigate against under- or over-  
runs is to have the sender always be a little faster.

While I understand that this will help keep the sink always filled it  
will not avoid buffer under runs, or am I misunderstanding something?

Also the only way for the source to keep up is to throw away samples at  
times.

Has anyone came up with an idea of how this problem could (should) be  
addressed in a proper way in gnu-radio? (I mean without changing hw.)

From a little test set up I have seen that I could program a sink and a  
source, referencing a common buffer. The buffer level (a smoothed  
version) could be the driving variable to a dynamically programmed  
sample rate converter that is set up so as to keep the buffer level  
constant.

Is this a too hakish attempt to address the problem?

Has anyone already tried this?

Is there a more straight forward way, i.e. using a regular input-output  
module?

I am thankful for any hints or comments.

Roland

–

* * *

\_ \_ | Roland Schwarz  
|_)(_ |  
| \_\_) | [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
\_\_\_\_\_\_\_\_| [http://www.blackspace.at](http://www.blackspace.at)

---

<div class="post-metadata">

**Author:** ![Roland\_Schwarz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bc8723/32.png) [@Roland\_Schwarz](https://www.ruby-forum.com/u/Roland_Schwarz)\
**Post date:** [April 7, 2015, 9:46pm UTC](https://www.ruby-forum.com/t/two-clock-drift-compensation-howto/241450/2 "2015-04-07T21:46:08Z")

</div>

Hi Roland,

I have used the method you suggest in the distant past to match sample  
rates of audio hardware with nominally equal but independent clocks. I  
found it worked “ok” as long as the resampler you are using can handle  
small dynamic offsets ie: +/- 0.1Hz without noticeable artifacts. The  
FIFO  
used to measure the difference in rate also adds some latency.

On Tue, Apr 7, 2015 at 7:34 AM, Roland Schwarz  
\<removed\_email\_address@domain.invalid
