From d23457e9aaf4862732780950fccf7e7d0c2031c1 Mon Sep 17 00:00:00 2001 From: Chrystian Huot Date: Tue, 26 May 2020 14:28:01 -0400 Subject: [PATCH] CSDR-AM script added to the examples folder --- docs/examples/csdr/README.md | 91 +++++++++++++++++++ docs/examples/csdr/csdr-am | 85 +++++++++++++++++ .../{ => trunk-recorder}/upload-call.sh | 0 3 files changed, 176 insertions(+) create mode 100644 docs/examples/csdr/README.md create mode 100755 docs/examples/csdr/csdr-am rename docs/examples/{ => trunk-recorder}/upload-call.sh (100%) diff --git a/docs/examples/csdr/README.md b/docs/examples/csdr/README.md new file mode 100644 index 0000000..808d485 --- /dev/null +++ b/docs/examples/csdr/README.md @@ -0,0 +1,91 @@ +# CSDR-AM + +The purpose of this shell script is to record multiple AM frequencies from a single RTL-SDR and creates individual audio files per conversation. + +## Requirements + +Tested on a linux box. + +* [csdr](https://github.com/ha7ilm/csdr) +* [sox](http://sox.sourceforge.net/) + +## Configurations + +### Within the script itself + +Change the the values to you needs. Make sure the `centered_freq` and `sampling_rate` covers the `freqs`. + +Note the syntax for `freqs` and `filenames`, they are arrays. + +Each filename template use sox multiple output mode syntax for file numbering (`%6n`). The static part is reused by `dirWatch` to distinguish which `talkgroup` to import to. + +```bash +audio_dir=./audio_files/air +device_id=00000001 +center_freq=119.4e6 +gain=38.6 +sampling_rate=2400000 +squelch=2e-4 + +freqs=(118.9e6 119.1e6 119.9e6) + +filenames=(118900000-%6n 119100000-%6n 119900000-%6n) +``` + +## Rdio Scanner + +Whenever a new file is being created by the `CSDR-AM` script, `Rdio Scanner` will pick it up and load it. + +Since the script create a file for each frequency which will have a size of `0` until the next conversation, we have to tell the `dirWatch` entry to delay the import for `4000` milliseconds. + +The system also needs to be defined. + +> For simplicy, talkgroup ids are defined with the same value as for the frequency. It makes it easier to change things afterwards. + +```json +"rdioScanner": { + "dirWatch": [ + { + "delay": 4000, + "deleteAfter": true, + "directory": "/home/radio/csdr/audio_files/air", + "extension": "wav", + "system": 61, + "talkgroup": ".*\\/(\\d+)-.*" + } + ], + "systems": [ + { + "id": 61, + "label": "AIRCRAFT", + "led": "cyan", + "talkgroups": [ + { + "id": 119100000, + "label": "YMX TOWER", + "name": "YMX Tower", + "tag": "Aircraft", + "group": "AIRCRAFT", + "frequency": 119100000 + }, + { + "id": 119900000, + "label": "YUL TOWER", + "name": "YUL Tower", + "tag": "Aircraft", + "group": "AIRCRAFT", + "frequency": 119900000 + }, + { + "id": 118900000, + "label": "YUL DA_SE", + "name": "YUL Dep/Arr S/E", + "tag": "Aircraft", + "group": "AIRCRAFT", + "frequency": 118900000 + } + ] + } + ] +} +``` \ No newline at end of file diff --git a/docs/examples/csdr/csdr-am b/docs/examples/csdr/csdr-am new file mode 100755 index 0000000..d4c5fbc --- /dev/null +++ b/docs/examples/csdr/csdr-am @@ -0,0 +1,85 @@ +#!/bin/bash + +## +## ############################################################################# +## Copyright (C) 2019-2020 Chrystian Huot +## +## 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, either version 3 of the License, or +## (at your option) any later version. +## +## 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 +## ############################################################################# +## + +## +## Begin of configurable values +## + +audio_dir=./audio_files/air +device_id=00000001 +center_freq=119.4e6 +gain=38.6 +sampling_rate=2400000 +squelch=2e-4 + +## List of frequencies covered by your RTL + +freqs=(118.9e6 119.1e6 119.9e6) + +## Filename tempaltes for each frequencies +## See sox documentation for multiple files output + +filenames=(118900000-%6n 119100000-%6n 119900000-%6n) + +## +## End of configurable values +## + +for i in ${!freqs[@]}; do + mkfifo /tmp/csdr_${device_id}_${freqs[i]}_iq.fifo + + mkfifo /tmp/csdr_${device_id}_${freqs[i]}_squelch.fifo +done + +trap cleanup EXIT + +test -d ${audio_dir} || mkdir -p ${audio_dir} || exit 1 + +trap "rm -f /tmp/csdr_${device_id}_*.fifo" EXIT + +for i in ${!freqs[@]}; do + cat /tmp/csdr_${device_id}_${freqs[i]}_iq.fifo | + csdr convert_u8_f | + csdr shift_addition_cc $(csdr =\(${center_freq}-${freqs[i]}\)/${sampling_rate}) | + csdr fir_decimate_cc 50 0.005 HAMMING | + csdr squelch_and_smeter_cc --fifo /tmp/csdr_${device_id}_${freqs[i]}_squelch.fifo --outfifo /dev/null 6e-5 600 | + csdr amdemod_cf | + csdr agc_ff | + csdr limit_ff | + csdr convert_f_s16 | + sox -c 1 -r 44100 -t s16 - "${audio_dir}/${filenames[i]}.wav" silence 1 0.50 0.1% 1 2.0 0.1% : newfile : restart & +done + +for i in ${!freqs[@]}; do + echo ${squelch} >/tmp/csdr_${device_id}_${freqs[i]}_squelch.fifo +done + +server="rtl_sdr -d ${device_id} -f ${center_freq} -g ${gain} -s ${sampling_rate} -" + +for i in ${!freqs[@]}; do + if [ $i == $((${#freqs[@]} - 1)) ]; then + server+=" > /tmp/csdr_${device_id}_${freqs[i]}_iq.fifo" + else + server+=" | tee /tmp/csdr_${device_id}_${freqs[i]}_iq.fifo" + fi +done + +eval ${server} diff --git a/docs/examples/upload-call.sh b/docs/examples/trunk-recorder/upload-call.sh similarity index 100% rename from docs/examples/upload-call.sh rename to docs/examples/trunk-recorder/upload-call.sh