File: sample_clock_offset.m

package info (click to toggle)
codec2 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 76,376 kB
  • sloc: ansic: 436,819; cpp: 2,091; objc: 1,736; sh: 1,510; python: 1,405; asm: 683; makefile: 605
file content (21 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
% sample_clock_offset.m
%
% David Rowe June 2017
%
% To simulate a sample clock offset we resample by a small amount
% using linear interpolation

function rx = sample_clock_offset(tx, sample_clock_offset_ppm)
  tin=1;
  tout=1;
  rx = zeros(1,length(tx));
  while tin < length(tx)
      t1 = floor(tin);
      t2 = ceil(tin);
      f = tin - t1;
      rx(tout) = (1-f)*tx(t1) + f*tx(t2);
      tout += 1;
      tin  += 1+sample_clock_offset_ppm/1E6;
  end
end