Recording SDR Receiver Audio to a File
Archive post.
Translated from Ukrainian.
Continuing the topic of getting more out of an OpenWebRX-based SDR receiver, here’s my recipe for recording the air to a file.
To record from the receiver’s raw stream, run this command:
nc -v 127.0.0.1 4951 | csdr convert_u8_f | csdr shift_addition_cc 0.1 | csdr fir_decimate_cc 181 0.000828675 HAMMING | csdr fmdemod_quadri_cf | csdr limit_ff | csdr deemphasis_nfm_ff 11025 | csdr fastagc_ff | csdr convert_f_s16 | sox -r 44100 -e unsigned -b 8 -c 1 -t raw - /tmp/hmm.ogg
Here the shift csdr shift_addition_cc 0.1 points to 144.800 MHz.
The shift is calculated like this:
csdr shift_addition_cc `python -c "print float(145000000-145350000)/2000000"`
де:
145000000 - центральна частота,
145350000 - потрібна частота,
2000000 - ширина смуги
If you play back /tmp/hmm.ogg, all you’ll hear is noise, because the squelch isn’t on.
The S-meter readings are written to the fifo /tmp/record_smeter_pipe. Based on those values we pick a squelch level and write it to the fifo /tmp/record_squelch_pipe.
There’s a catch here. Recording won’t start until we write something to the fifo
echo "0" > /tmp/record_squelch_pipe
and start reading the S-meter data in a separate thread
cat /tmp/record_smeter_pipe
By the way, this is how you create the fifo pipes:
mkfifo /tmp/record_squelch_pipe
mkfifo /tmp/record_smeter_pipe
Once the squelch value is chosen (mine is 0.0005), the reading problem goes away by redirecting the stream with --outfifo /dev/null. The squelch value, though, has to be written before the recording command runs. Like this: echo "0.0005" > /tmp/record_squelch_pipe
echo "0.0005" > /tmp/record_squelch_pipe
nc -v 127.0.0.1 4951 | csdr convert_u8_f | csdr shift_addition_cc -0.25 | csdr fir_decimate_cc 181 0.000828675 HAMMING | csdr squelch_and_smeter_cc --fifo /tmp/record_squelch_pipe --outfifo /dev/null 5 1 | csdr fmdemod_quadri_cf | csdr limit_ff | csdr deemphasis_nfm_ff 11025 | csdr fastagc_ff | csdr convert_f_s16 | sox -r 11025 -e signed -b 16 -c 1 -t raw - /tmp/hmm_sq.wav
That’s it: /tmp/hmm_sq.wav now holds a recording of the air with no noise.