8
8
# cd ~ && git clone git@github.com:jks-prv/kiwiclient.git
9
9
# 3. Install Hamlib cli tools
10
10
11
+ set -x
11
12
MY_PATH=` dirname $0 `
12
13
BUILD_PATH=` echo $MY_PATH /../build_* /src`
13
14
PATH=${PATH} :${BUILD_PATH} :${HOME} /kiwiclient
@@ -25,24 +26,27 @@ serialPort="/dev/ttyUSB0"
25
26
rxwavefile=0
26
27
soundDevice=" plughw:CARD=CODEC,DEV=0"
27
28
txstats=0
29
+ stationid=" "
28
30
29
31
function print_help {
30
32
echo
31
33
echo " Automated Over The Air (OTA) voice test for FreeDV HF voice modes"
32
34
echo
33
- echo " usage ./ota_voice_test.sh [options] SpeechFile [kiwi_url]"
35
+ echo " usage ./ota_voice_test.sh [options] SpeechWaveFile [kiwi_url]"
34
36
echo " or:"
35
37
echo " usage ./ota_voice_test.sh -r rxWaveFile"
36
38
echo
37
- echo " -c dev The sound device (in ALSA format on Linux, CoreAudio for macOS)"
38
- echo " -d debug mode; trace script execution"
39
- echo " -g SSB (analog) compressor gain"
39
+ echo " -c dev The sound device (in ALSA format on Linux, CoreAudio for macOS)"
40
+ echo " -d debug mode; trace script execution"
41
+ echo " -g SSB (analog) compressor gain"
42
+ echo " -i StationIDWaveFile Prepend this file to identify transmission (should be 8KHz mono)"
40
43
echo " -m mode 700c|700d|700e"
41
- echo " -o model select radio model number ('rigctl -l' to list)"
42
- echo " -r Rx wave file mode: Rx process supplied rx wave file"
43
- echo " -s port The serial port (or hostname:port) to connect to for TX, default /dev/ttyUSB0"
44
- echo " -t Tx only, useful for manually observing SDRs"
45
- echo " -x Generate tx.wav file and exit"
44
+ echo " -o model select radio model number ('rigctl -l' to list)"
45
+ echo " -r Rx wave file mode: Rx process supplied rx wave file"
46
+ echo " -s port The serial port (or hostname:port) to control SSB radio,"
47
+ echo " default /dev/ttyUSB0"
48
+ echo " -t Tx only, useful for manually observing SDRs"
49
+ echo " -x Generate tx.wav file and exit"
46
50
echo
47
51
exit
48
52
}
@@ -86,7 +90,7 @@ function process_rx {
86
90
plot_specgram(s, 8000, 200, 3000); print('spec.jpg', '-djpg'); \
87
91
quit" | octave-cli -p ${CODEC2} /octave -qf > /dev/null
88
92
# attempt to decode
89
- freedv_rx ${mode} ${rx} - -v --highpassthroughgain 2> rx_stats.txt | sox -t .s16 -r 8000 -c 1 - rx_freedv.wav
93
+ freedv_rx ${mode} ${rx} - -v --highpassthroughgain 2> rx_stats.txt | sox -t .s16 -r $speechFs -c 1 - rx_freedv.wav
90
94
cat rx_stats.txt | tr -s ' ' | cut -f5 -d' ' | awk ' $0==($0+0)' > sync.txt
91
95
cat rx_stats.txt | tr -s ' ' | cut -f10 -d' ' | awk ' $0==($0+0)' > snr.txt
92
96
# time domain plot of output speech, SNR, and sync
@@ -120,6 +124,11 @@ case $key in
120
124
shift
121
125
shift
122
126
;;
127
+ -i)
128
+ stationid=" $2 "
129
+ shift
130
+ shift
131
+ ;;
123
132
-o)
124
133
model=" $2 "
125
134
shift
175
184
176
185
speechfile=" $1 "
177
186
if [ ! -f $speechfile ]; then
178
- echo " Can't find ${speechfile} !"
187
+ echo " Can't find input speech wave file: ${speechfile} !"
179
188
exit 1
180
189
fi
181
190
191
200
echo $mode
192
201
193
202
# create compressed analog
203
+ speechfile_raw_8k=$( mktemp)
204
+ comp_in=$( mktemp)
194
205
speech_comp=$( mktemp)
195
206
speech_freedv=$( mktemp)
196
- analog_compressor $speechfile $speech_comp $gain
207
+ # If 16kHz input files for 2020x, we need an 8kHz version for SSB
208
+ sox $speechfile -r 8000 -t .s16 -c 1 $speechfile_raw_8k
209
+ if [ -z $stationid ]; then
210
+ cp $speechfile_raw_8k $comp_in
211
+ else
212
+ # append station ID and apply analog compression
213
+ stationid_raw_8k=$( mktemp)
214
+ sox $stationid -r 8000 -t .s16 -c 1 $stationid_raw_8k
215
+ cat $stationid_raw_8k $speechfile_raw_8k > $comp_in
216
+ fi
217
+ analog_compressor $comp_in $speech_comp $gain
218
+
219
+ # determine sample rate of input file we require for freedv_tx
220
+ speechFs=8000
221
+ if [ " $mode " == " 2020" ] || [ " $mode " == " 2020A" ] || [ " $mode $" == " 2020B" ]; then
222
+ speechFs=16000
223
+ fi
197
224
198
225
# create modulated FreeDV, with compressor enabled
199
- freedv_tx $mode $speechfile $speech_freedv --clip 1
226
+ sox $speechfile -t .s16 -r $speechFs - | freedv_tx $mode - $speech_freedv --clip 1
200
227
cat $speech_comp $speech_freedv > tx.raw
201
228
sox -t .s16 -r 8000 -c 1 tx.raw tx.wav
202
229
0 commit comments