rtty-mix.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # $1 text file (..hopefully prepared for RTTY..)
  3. # minimodem -i -q --rx rtty -a --alsa=CODEC
  4. # rigctld -T localhost -m 1 -r /dev/ttyUSB0 -p /dev/ttyUSB1 -P RTS
  5. CALLSIGNBANNER=/home/cjb/rtty/callsign-one-minute.wav
  6. TXAUDIOSCRIPT=/home/cjb/Bin/tx_wav.sh
  7. RTTYWAV=/tmp/$$.r.wav
  8. TONEWAV=/tmp/$$.t.wav
  9. TXRTTYWAV=/tmp/$$.tx.wav
  10. TMPWAV=/tmp/$$.tmp.wav
  11. echo "Input details: (~3400/chars in 10 minutes)"
  12. wc $1|awk '{print "Characters "$3", Lines "$1}'
  13. cat $1| sed -e 's/$/\r/g' | \
  14. minimodem -5 --stopbits 1.5 -M 2125 -S 2295 --write rtty -f $RTTYWAV
  15. echo -n "Generated audio file length: "
  16. dur=`soxi -D $RTTYWAV`
  17. echo $dur
  18. sox --null $TONEWAV synth $dur sine 91.5
  19. sox --combine mix --volume 0.74 $RTTYWAV --volume 0.24 $TONEWAV $TMPWAV
  20. mv -f $TMPWAV $RTTYWAV
  21. echo "Mixing with "$CALLSIGNBANNER" (ignore EOF warning) "
  22. sox $CALLSIGNBANNER -p repeat 60 trim 0 $dur \
  23. | sox --volume 0.66 - --combine mix --volume 0.65 $RTTYWAV -t wav $TXRTTYWAV lowpass 2500 gain 1.25
  24. ls -l $TXRTTYWAV
  25. ###
  26. RIG=2
  27. RADDEV=localhost:4532
  28. a=`pgrep rigctld`X
  29. userig="0"
  30. if [ "$a" == "X" ]
  31. then
  32. echo "Starting rigctld"
  33. rigctld -T localhost -m 1 -s 38400 -r /dev/ttyUSB0 -p /dev/ttyUSB1 -P RTS &
  34. sleep 1
  35. userig="1"
  36. fi
  37. ###
  38. echo -n "^C to abort, Enter to start transmission >"
  39. read a
  40. rigctl -m $RIG -r $RADDEV T 1
  41. sleep 1
  42. echo -n "Transmitting audio"
  43. mplayer -msglevel all=-1:statusline=5 -ao alsa:device=hw=CODEC $TXRTTYWAV
  44. sleep 1
  45. rigctl -m $RIG -r $RADDEV T 0
  46. ###
  47. if [ userig == "1" ]
  48. then
  49. echo "Killing rigctld"
  50. killall rigctld
  51. fi
  52. rm -f $RTTYWAV $TONEWAV $TXRTTYWAV $TMPWAV