#!/bin/bash # cqrlog voice keyer script # paplay can handle common audio formats such as mp3, wav, etc # let the shell expand $1 so it finds any extension (.mp3, .wav, etc) # use echo since NO pathname expansion takes place with variable assignment # involving only literals or references to other variables, but it does # in command substition FILE=$(echo ~/.config/cqrlog/voice_keyer/${1}.*) RC_MOD="2" # rigctl model id (hamlib net rigctl RC_DEV="localhost:4532" # rigctl device PA_SINK="TxCable" # portaudio sink for my tx audio if [ -r "$FILE" ] then echo "Found "$FILE # ask the rig what it's PTT state is r=$(rigctl -m $RC_MOD -r $RC_DEV t) # we expect the answer to be 0 for RX if [ "$r" = "0" ] then echo "Rigctl is up" else echo "Rigctl is NOT up -- exiting" exit 1 fi # see if another copy of paplay is running p=$(pidof paplay) # if another copy of paplay is running, assume it's ours if [ -z "$p" ] then echo "No other copy is playing" else echo "Another copy is playing -- exiting" exit 1 fi # PTT settings: ‘0’ (RX), ‘1’ (TX), ‘2’ (TX mic), or ‘3’ (TX data) echo "PTT on" rigctl -m $RC_MOD -r $RC_DEV T 2 # Note: pihpsdr Mic Lvl is high during this playback # Note: --volume=N doesn't seem to do anything (N=0..65536) echo "Play" paplay --device $PA_SINK --volume=65535 $FILE echo "PTT off" rigctl -m $RC_MOD -r $RC_DEV T 0 fi