-
Notifications
You must be signed in to change notification settings - Fork 4
/
slot_qpsk_slicer.ny
40 lines (36 loc) · 1.19 KB
/
slot_qpsk_slicer.ny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;nyquist plug-in
;version 3
;type analyze
;name "Timeslotted QPSK bit slicer"
;control symbolrate "Symbol rate" float "Hz" 18000 0 1000000
;control nsyms "Symbols per slot" int "symbols" 255 0 1000000
;; Divide signal into fixed-length timeslots and estimate symbol timing
;; independently for each slot. Print one slot per line.
(setq oversamp 8)
(setq nsamps (* nsyms oversamp))
(let ((resampled (force-srate (* oversamp symbolrate) s)))
(loop
(let ((a-i (snd-fetch-array (aref resampled 0) nsamps nsamps))
(a-q (snd-fetch-array (aref resampled 1) nsamps nsamps))
(best-timing-phase 0) (best-sum 0))
(unless a-i (return)) ;; Stop when there's no more signal
(dotimes (tphase 8)
(let ((s 0))
(dotimes (symn nsyms)
(setq s (+ s (abs (aref a-i (+ tphase (* 8 symn))))
(abs (aref a-q (+ tphase (* 8 symn))))))
)
(if (> s best-sum)
(progn (setq best-timing-phase tphase)
(setq best-sum s)))
;;(prin1 s) (princ " ")
)
)
(dotimes (symn nsyms)
(prin1 (if (< (aref a-q (+ best-timing-phase (* 8 symn))) 0) 1 0))
(prin1 (if (< (aref a-i (+ best-timing-phase (* 8 symn))) 0) 1 0))
)
)
(princ "\n")
)
)