开云体育

Pulseaudio based VOX PTT - Possible interest only


 

开云体育

A little bit off topic.

I have been chasing down an audio buffer underrun problem that only happens with direwolf. I am also running pulseaudio despite not being a good idea for direwolf! I am making some progress with this, that I wont go into with this post though. What I wanted to mention is that part of the problem seems to be that the PTT window time shifts with respect to the audio out. I suspect a hamlib (my rig only) issue rather than a variable audio ring buffer/delay thing. Minimal problem for 30m APRS beacons, but a real mess for 2m ISS passes or AX25 connected mode.

Some time ago I wrote a pulseaudio VOX like PTT script to run EasyDRF (under wine) that I though I would share for interest. I recently reworked it for the fast turnaround needed for ARDOP. It now works "perfectly" in replacing the use of the PTT RIG 2 localhost:4532 line in the direwolf conf file. It detects the presence of flrig or rigctld as needed.

Basically it just sits pushing an audio stream into a FIFO/pipe at 48kHz and samples that 1260 bytes at a time. Any deviation from audio "zero" asserts the PTT. The 1260 I got by first running the dd command without iflag=fullblock and a bs of 4800 odd, then seeing how many bytes were actually read (in stderr), adding maybe 20% and plugging it all back into the dd line. The audio stream is not perfectly synchronous hence the need for the iflag-fullblock. Doing the maths it looks like the worse case delay before PTT assert is in the order of 25-50mS which can easily be countered with an additional TXdelay.

alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor is the pulse device name used for a few types of Icom transceivers. pactl list shows all.

This cured my direwolf PTT/audio window problem.

Cheers Bob VK2YQA

=============

#!/bin/bash

export DRFACTIVE=TRUE
export PTTSTATE=OFF

if [ "`ps -C flrig --no-headers`" != "" ] ; then
??? PTT1=flptt1
??? PTT0=flptt0
elif [ "`ps -C rigctld --no-headers`" != "" ] ; then
??? PTT1=hlptt1
??? PTT0=hlptt0
else
??? /usr/local/bin/rigctld -m 3068 -x 2 -c 0x7c -s 19200 -r /dev/icom9100a &
??? PTT1=hlptt1
??? PTT0=hlptt0
fi

# Output to continuous pipe
killall -TERM parec 2>/dev/null
rm -f /tmp/voxptt.raw /tmp/*drfpttstderr.txt
mkfifo /tmp/voxptt.raw
(sleep 4 && parec --rate=48000 --format=u8 --channels=1 --channel-map=front-left -d alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor >/tmp/voxptt.raw) &


( while [ "$DRFACTIVE" = "TRUE" ] ; do
if [ "`dd bs=1260 count=1 iflag=fullblock 2>>/tmp/main-drfpttstderr.txt | xxd -p -c 1 | grep -v 80`" == "" ] ; then

??????? # Ptt Assert RX
??????? if [ "$PTTSTATE" = "ON" ] ; then
??????????? $PTT0 >/dev/null 2>&1 &
??????????? PTTSTATE=OFF
??????????? echo .
??????????? echo TX2RX | tee -a /tmp/main-drfpttstderr.txt
??????? fi
??????? echo -n "Off "?? ?
else
??????? # Ptt Assert TX
??????? if [ "$PTTSTATE" = "OFF" ] ; then
??????????? $PTT1 >/dev/null 2>&1 &
??????????? PTTSTATE=ON
??????????? echo .
??????????? echo RX2TX | tee -a /tmp/main-drfpttstderr.txt?????? ?
??????? fi
??????? echo -n "On? "
fi

done) </tmp/voxptt.raw


===========

hlppt1

#!/bin/bash
#
echo "\set_ptt 1"|nc -w 1 -q 0 localhost 4532
exit 0

hlppt0

#!/bin/bash
#
echo "\set_ptt 0"|nc -w 1 -q 0 localhost 4532
exit 0

flptt1

#!/bin/bash
curl -X POST -d '<?xml version="1.0"?><methodCall><methodName>rig.set_ptt</methodName><params><param><value><int>1</int></value></param></params></methodCall>'
exit 0

flptt0

#!/bin/bash
curl -X POST -d '<?xml version="1.0"?><methodCall><methodName>rig.set_ptt</methodName><params><param><value><int>0</int></value></param></params></methodCall>'
exit 0


 

great!