-
Notifications
You must be signed in to change notification settings - Fork 112
/
cut_sample
executable file
·81 lines (64 loc) · 2.06 KB
/
cut_sample
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
file=$1
rate=$2
start=$3
end=$4
min=$5
max=$6
center=$7
echo
echo Running as: $file $rate [$start/$end] [$min/$max] $center
bbs=8 # byte per sample
sbyte=`echo "$start $bbs* p "|dc`
lbyte=`echo "$end $start - $bbs *p" |dc`
echo start/end: $sbyte $lbyte
time=`echo "$start 1000 * $rate / p"|dc`
echo time: $time
window=`echo $max $min -p|dc`
offset=`echo $max $min + 2/ $center -p|dc`
echo win/off: $window $offset
dec=1
if [ $rate -gt 1000000 ] ; then
dec=`echo $rate 500000 / p|dc`
fi
osr=`echo $rate $dec / p|dc`
of=sample-$time.raw
# cut section from source
dd if=${file} of=$of bs=1 skip=$sbyte count=$lbyte 2>/dev/null || exit 1
# downmix selected signal
cut_and_downmix.py -f 0 -w $window -o $offset -c $center --verbose -r $rate $of >sample.txt.cut || exit 1
of2=`tail -1 sample.txt.cut|awk '{print $2}'`
of3=${of2%.cut}.peaks
of4=${of2%.cut}.turned
if [ ! -f $of2 ] ; then
inspectrum $of &
exit 1
fi
demod.py -v -d -r $osr $of2 >sample.txt.demod
rm -f sample.txt
grep ^MODE sample.txt.cut | tee -a sample.txt
grep ^RAW sample.txt.demod >> sample.txt
off=`grep "^frequency offset:" sample.txt.demod |awk '{print $3}'`
echo "FreqOffset: $off" |tee -a sample.txt
if false ; then # Attempt to correct frequency offset
cut_and_downmix.py -f $off -w $window -o $offset -c $center --verbose -r $rate $of >sample.txt.cut2
of2b=`tail -1 sample.txt.cut2|awk '{print $2}'`
demod.py -v -c -r $rate $of2b > sample.txt.demod2
grep ^MODE sample.txt.cut2 | tee -a sample.txt
grep ^RAW sample.txt.demod2 >> sample.txt
grep ^RAW sample.txt.demod2 >> sample.txt.demod
off2=`grep "^frequency offset:" sample.txt.demod2 |awk '{print $3}'`
echo "FreqOffset: $off2" |tee -a sample.txt
fi
grep ^RAW sample.txt.demod | iridium-parser.py |grep -v Warning >> sample.txt
(
fmt -s -w 70 < sample.txt > sample.msg
inspectrum -r $rate $of2 &
pid=$!
n=`echo 3000 $dec / p|dc`
gr_time_plot_c -N $n -r $rate $of2 $of3 $of4 &
pid2=$!
xmessage -center -default okay -fn "-bitstream-courier 10 pitch-medium-r-*-*-*-240-*-*-*-*-*-*" -file sample.msg
kill $pid $pid2
rm -f sample.msg 2>/dev/null
) &