aboutsummaryrefslogtreecommitdiff
path: root/octave/sample_clock_offset.m
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2025-07-25 10:17:14 +0300
committerMarin Ivanov <[email protected]>2026-01-18 20:09:26 +0200
commit0168586485e6310c598713c911b1dec5618d61a1 (patch)
tree6aabc2a12ef8fef70683f5389bea00f948015f77 /octave/sample_clock_offset.m
Initial commitHEADmaster
* codec2 cut-down version 1.2.0 * Remove codebook and generation of sources * remove c2dec c2enc binaries * prepare for emscripten
Diffstat (limited to 'octave/sample_clock_offset.m')
-rw-r--r--octave/sample_clock_offset.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/octave/sample_clock_offset.m b/octave/sample_clock_offset.m
new file mode 100644
index 0000000..5169178
--- /dev/null
+++ b/octave/sample_clock_offset.m
@@ -0,0 +1,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
+