-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.sh
78 lines (68 loc) · 2.48 KB
/
example.sh
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
#!/bin/bash
#
# This file is part of the sdrterm distribution
# (https://github.com/peads/sdrterm).
# with code originally part of the demodulator distribution
# (https://github.com/peads/demodulator).
# Copyright (c) 2023-2024 Patrick Eads.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
####
# Usage: ./example.sh <wave_file>
####
if [[ -z ${SDRTERM_EXEC} ]]; then
SDRTERM_EXEC="python -m sdrterm";
fi
if [[ -z ${DSD_CMD} ]]; then
DSD_CMD="dsd -q -i - -o /dev/null -n";
fi
if [[ -z ${OUT_PATH} ]]; then
OUT_PATH=/tmp;
fi
echo $SDRTERM_EXEC;
echo $DSD_CMD;
echo $OUT_PATH;
function runStdinTest {
fileName="${OUT_PATH}/out${4}${6}.wav";
echo "$fileName";
time sox -q -D -twav ${1} -traw -b${2} -e${3} ${6} - 2>/dev/null \
| ${SDRTERM_EXEC} -w5000 -e${4} -r48000 ${5} 2>/dev/null \
| sox -q -D -v0.5 -traw -r24k -b64 -ef - -traw -r48k -b16 -es - 2>/dev/null \
| ${DSD_CMD} -w "$fileName" 2>&1 | grep "Total" - | grep -E --color=always '[0-9]+' -;
}
function runFileInTest {
fileName="${OUT_PATH}/out${2}.wav";
echo "$fileName";
time ${SDRTERM_EXEC} -i ${1} -w5k ${3} 2>/dev/null \
| sox -q -v0.8 -D -traw -ef -b64 -r24k - -traw -es -b16 -r48k - 2>/dev/null \
| ${DSD_CMD} -w "$fileName" 2>&1 | grep "Total" - | grep -E --color=always '[0-9]+' -;
rm -f /tmp/tmp.wav;
}
echo "START basic raw stdin test";
runStdinTest "$1" "16" "s" "h"
runStdinTest "$1" "8" "unsigned-int" "B" "--correct-iq"
runStdinTest "$1" "32" "s" "i"
runStdinTest "$1" "32" "f" "f"
runStdinTest "$1" "64" "f" "d"
runStdinTest "$1" "16" "s" "h" "-X" "-B"
runStdinTest "$1" "32" "s" "i" "-X" "-B"
runStdinTest "$1" "32" "f" "f" "-X" "-B"
runStdinTest "$1" "64" "f" "d" "-X" "-B"
printf "END basic raw stdin test\n\n";
echo "START basic wave file test";
runFileInTest "$1" "i16"
sox -q -D -twav ${1} -twav -eunsigned-int -b8 /tmp/tmp.wav 2>/dev/null;
runFileInTest "/tmp/tmp.wav" "u8" "--correct-iq"
sox -q -D -twav ${1} -twav -B /tmp/tmp.wav 2>/dev/null;
runFileInTest "/tmp/tmp.wav" "i16X"