Set fldigi's sound card in radio configure

fldigi gets PortAudio as its audio system, with the radio's card for
capture and playback. It opens devices by name, so radio lists PortAudio's
devices through the system library, as fldigi does, and picks PipeWire's
names for the card (through PortAudio's JACK support) where just one
device has them, or else ALSA's, with the card's number. Devices that are
unset, a default, or the same card under an old number are replaced; a
device you chose, or fldigi on PulseAudio or OSS, is left alone unless
--force.

not1mm now uses the same device list, instead of asking its own Python's
sounddevice, which reads the same library. POTACAT is the only program
whose sound card is left for you to choose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-28 13:19:04 -07:00
co-authored by Claude Opus 5.5
parent c2cb2bc2f4
commit 8020cdc061
5 changed files with 194 additions and 79 deletions
+2 -7
View File
@@ -18,13 +18,8 @@ control a radio.
- [ ] `radio configure`, the rest. It writes the rigctld user service and
points WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm, QLog, POTACAT
and Graywolf at it. Still to do:
- [ ] Sound cards for fldigi and POTACAT. fldigi (PortAudio) names a card
with its number, as in "USB Audio Device: - (hw:3,0)", which can
change between boots. PortAudio also lists PipeWire's devices through
JACK under stable names, as not1mm now uses; check whether fldigi's
PortAudio list includes them. POTACAT keeps browser device ids, which
only it can see. WSJT-X, JS8Call, Dire Wolf, Graywolf and not1mm are
done
- [ ] POTACAT's sound card. It keeps browser (Chromium) device ids, which
only it can see; every other program's is done
- [ ] flrig can't use rigctld, so it can't run alongside it. Say so, or
offer flrig as the controller instead
- [ ] More than one radio at once: a rigctld for each, on its own port
+2 -2
View File
@@ -67,9 +67,9 @@ Probing opens the port, which raises its DTR and RTS lines for a moment before `
`radio configure` sets up the radio for HamPack's programs. It asks the radio what it is and at what baud rate it answers. Then it runs Hamlib's rigctld for it, as the `hampack-rigctld` systemd user service on 127.0.0.1:4532, and points WSJT-X, JS8Call, Pat, fldigi, Dire Wolf, not1mm, QLog, POTACAT and Graywolf at rigctld, with PTT through it. QLog gets a rig profile named HamPack in its log, which is backed up first. Graywolf's channels that transmit get PTT through rigctld; it's stopped for that with sudo, and started again. They then share the radio through rigctld, without fighting over its serial port. Quit them first, since they save their settings when they quit.
It also gives WSJT-X, JS8Call, Dire Wolf and not1mm's voice keyer the radio's sound card. WSJT-X and JS8Call get it as PipeWire names it, so PipeWire must be running. not1mm gets PipeWire's name for it too where it can, since ALSA's name for it has a card number that can change between boots; if it does, run `radio configure` again. If Graywolf has no channels yet, it gets one on the radio's sound card, for 1200 baud APRS.
It also gives WSJT-X, JS8Call, fldigi, Dire Wolf and not1mm's voice keyer the radio's sound card. WSJT-X and JS8Call get it as PipeWire names it, so PipeWire must be running. fldigi and not1mm get PipeWire's name for it too where PortAudio lists it (through PipeWire's JACK support), since ALSA's name for it has a card number that can change between boots; if it does, run `radio configure` again. If Graywolf has no channels yet, it gets one on the radio's sound card, for 1200 baud APRS.
`radio configure` only fills in rig and sound settings you haven't set (a sound device of "default" or "pipewire" counts as not set). `radio configure --force` replaces them, and every file it changes is backed up first. With more than one radio plugged in, give the number `radio` lists for it: `radio configure 2`. For a radio it can't tell apart from others, give its Hamlib model number: `radio configure --model 2045`. Choose the radio's sound card yourself in fldigi and POTACAT; `radio configure` says which it is.
`radio configure` only fills in rig and sound settings you haven't set (a sound device of "default" or "pipewire" counts as not set). `radio configure --force` replaces them, and every file it changes is backed up first. With more than one radio plugged in, give the number `radio` lists for it: `radio configure 2`. For a radio it can't tell apart from others, give its Hamlib model number: `radio configure --model 2045`. Choose the radio's sound card yourself in POTACAT; `radio configure` says which it is.
The radios it knows are in `radios.conf`. If your radio isn't recognised, or answers with something `radio` doesn't know, please open an issue with what `radio detect --probe` printed.
+6 -2
View File
@@ -66,8 +66,12 @@ Dire Wolf, not1mm, QLog and POTACAT quit:
6. Open fldigi (after running it once, so it has settings). Configure >
Rig Control > Hamlib shows rig control on, "Hamlib NET rigctl",
127.0.0.1:4532 and "PTT via Hamlib command". The frequency follows the
radio, and T/R keys it. The settings were checked against fldigi 4.1's
source; Arch has 4.2, so note anything it doesn't pick up.
radio, and T/R keys it. Configure > Soundcard > Devices shows PortAudio,
with the radio's card for capture and playback (PipeWire's names, under
"JACK Audio Connection Kit devices", if PipeWire's JACK support is
installed), and the waterfall shows the band. The settings were checked
against fldigi 4.1's source; Arch has 4.2, so note anything it doesn't
pick up.
7. Run Dire Wolf with `direwolf -c ~/.local/state/HamPack/conf.d/direwolf.conf`.
It should open plughw:CARD=...,DEV=0 and not complain about
"PTT RIG 2 127.0.0.1:4532". If it says RIG needs hamlib support, its
+113 -46
View File
@@ -654,9 +654,12 @@ xml_set() {
}
# fldigi: rig control through rigctld (Hamlib's NET rigctl, model 2), with PTT
# by Hamlib, unless it has rig control set up already
# by Hamlib, unless it has rig control set up already, and the radio's sound
# card through PortAudio. configure_fldigi CARD_NUMBER
configure_fldigi() {
local tag
local tag set_rig=1 set_sound=0 in_device out_device audio current_in current_out i
local tags=() values=()
SAID=() LEFT=()
if ! command -v fldigi > /dev/null; then
report fldigi "not installed"
return
@@ -669,28 +672,61 @@ configure_fldigi() {
report fldigi "skipped, because it's running and would overwrite its settings when it quits. Quit it and run \`radio configure\` again"
return
fi
if [ "$(xml_get "$FLDIGI_CONF" CHKUSEHAMLIBIS)" = 1 ] && [ "$(xml_get "$FLDIGI_CONF" HAMRIGMODEL)" = 2 ] &&
[ "$(xml_get "$FLDIGI_CONF" HAMRIGDEVICE)" = "$RIGCTLD_ADDR" ]; then
report fldigi "already set up"
return
fi
if (( ! FORCE )); then
set_rig=0
elif (( ! FORCE )); then
for tag in CHKUSEHAMLIBIS CHKUSERIGCATIS CHKUSEXMLRPCIS CLIENT_TO_FLRIG; do
if [ "$(xml_get "$FLDIGI_CONF" "$tag")" = 1 ]; then
report fldigi "left alone: it has rig control set up already. \`radio configure --force\` replaces that"
return
set_rig=0
LEFT+=("its rig control")
break
fi
done
fi
back_up "$FLDIGI_CONF"
if ! { xml_set "$FLDIGI_CONF" CHKUSEHAMLIBIS 1 && xml_set "$FLDIGI_CONF" CHKUSERIGCATIS 0 &&
xml_set "$FLDIGI_CONF" CHKUSEXMLRPCIS 0 && xml_set "$FLDIGI_CONF" CLIENT_TO_FLRIG 0 &&
xml_set "$FLDIGI_CONF" HAMRIGMODEL 2 && xml_set "$FLDIGI_CONF" HAMRIGDEVICE "$RIGCTLD_ADDR" &&
xml_set "$FLDIGI_CONF" HAMLIBCMDPTT 1; }; then
report fldigi "couldn't change $FLDIGI_CONF"
return 1
if (( set_rig )); then
tags+=(CHKUSEHAMLIBIS CHKUSERIGCATIS CHKUSEXMLRPCIS CLIENT_TO_FLRIG HAMRIGMODEL HAMRIGDEVICE HAMLIBCMDPTT)
values+=(1 0 0 0 2 "$RIGCTLD_ADDR" 1)
SAID+=("rig control through rigctld, PTT by Hamlib")
fi
report fldigi "rig control through rigctld, PTT by Hamlib"
if [ -n "$1" ]; then
if in_device="$(portaudio_name in "$1")" && out_device="$(portaudio_name out "$1")"; then
# AUDIOIO is 1 for PortAudio and 3 for none; 0 (OSS) and 2 (PulseAudio) are your choice
audio="$(xml_get "$FLDIGI_CONF" AUDIOIO)"
current_in="$(xml_get "$FLDIGI_CONF" PORTINDEVICE)"
current_out="$(xml_get "$FLDIGI_CONF" PORTOUTDEVICE)"
if [ "$audio" = 1 ] && [ "$current_in" = "$in_device" ] && [ "$current_out" = "$out_device" ]; then
:
elif (( FORCE )) || { [[ "${audio:-3}" =~ ^(1|3|-1)$ ]] &&
may_replace_device "$current_in" "$in_device" && may_replace_device "$current_out" "$out_device"; }; then
set_sound=1
tags+=(AUDIOIO PORTINDEVICE PORTININDEX PORTOUTDEVICE PORTOUTINDEX)
values+=(1 "$in_device" -1 "$out_device" -1)
SAID+=("sound card \"$out_device\"")
else
LEFT+=("its sound card")
fi
else
SAID+=("choose its sound card yourself: PortAudio doesn't list the radio's")
fi
fi
if [ ${#tags[@]} -gt 0 ]; then
back_up "$FLDIGI_CONF"
for i in "${!tags[@]}"; do
xml_set "$FLDIGI_CONF" "${tags[i]}" "$(xml_escape "${values[i]}")" || { report fldigi "couldn't change $FLDIGI_CONF"; return 1; }
done
fi
say_changes fldigi
}
# Escape a value for an XML element
xml_escape() {
local v="${1//&/&amp;}"
v="${v//</&lt;}"
printf '%s\n' "${v//>/&gt;}"
}
# Print the value of the first line for a Dire Wolf setting: dw_get FILE KEYWORD
@@ -779,36 +815,68 @@ configure_direwolf() {
report "Dire Wolf" "$message"
}
# Print the output devices not1mm can play to, as "NAME<tab>HOST API", one to
# a line, using the sounddevice library in not1mm's own Python
not1mm_outputs() {
local python="${UV_TOOL_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/uv/tools}/not1mm/bin/python"
[ -x "$python" ] || return 1
"$python" -I -c '
import sounddevice as sd
for d in sd.query_devices():
if d["max_output_channels"] > 0:
print(d["name"] + "\t" + sd.query_hostapis(d["hostapi"])["name"])
' 2> /dev/null
# Print the sound devices PortAudio lists, as fldigi and not1mm (through its
# sounddevice library) see them: "NAME<tab>HOST API<tab>INPUTS<tab>OUTPUTS",
# one to a line
portaudio_devices() {
python3 -I -c '
import ctypes, os, sys
class DeviceInfo(ctypes.Structure):
_fields_ = [("structVersion", ctypes.c_int), ("name", ctypes.c_char_p), ("hostApi", ctypes.c_int),
("maxInputChannels", ctypes.c_int), ("maxOutputChannels", ctypes.c_int)]
class HostApiInfo(ctypes.Structure):
_fields_ = [("structVersion", ctypes.c_int), ("type", ctypes.c_int), ("name", ctypes.c_char_p)]
try:
pa = ctypes.CDLL("libportaudio.so.2")
except OSError:
sys.exit(1)
pa.Pa_GetDeviceInfo.restype = ctypes.POINTER(DeviceInfo)
pa.Pa_GetHostApiInfo.restype = ctypes.POINTER(HostApiInfo)
# PortAudio and ALSA complain on stderr while they look for devices
saved, null = os.dup(2), os.open(os.devnull, os.O_WRONLY)
os.dup2(null, 2)
try:
if pa.Pa_Initialize() != 0:
sys.exit(1)
for i in range(pa.Pa_GetDeviceCount()):
d = pa.Pa_GetDeviceInfo(i).contents
api = pa.Pa_GetHostApiInfo(d.hostApi).contents.name.decode(errors="replace")
print("%s\t%s\t%d\t%d" % (d.name.decode(errors="replace"), api, d.maxInputChannels, d.maxOutputChannels))
sys.stdout.flush()
pa.Pa_Terminate()
finally:
os.dup2(saved, 2)
'
}
# Print the name not1mm's voice keyer should use for the radio's sound card:
# Print PortAudio's name for the radio's sound card, for input or output:
# PipeWire's description of it, through PortAudio's JACK support, which stays
# the same from boot to boot. Failing that, ALSA's name for it, which has the
# card's number in it: "USB Audio CODEC: USB Audio (hw:1,0)".
# not1mm_device CARD_NUMBER
not1mm_device() {
local outputs
outputs="$(not1mm_outputs)" || return 1
if [ -n "$PW_OUT_DESC" ] && [ "$(cut -f1 <<< "$outputs" | grep -cxF "$PW_OUT_DESC")" -eq 1 ]; then
echo "$PW_OUT_DESC"
elif [ -n "$1" ]; then
cut -f1 <<< "$outputs" | grep -F "(hw:$1," | head -1 | grep .
# the same from boot to boot, if just one device has it. Failing that, ALSA's
# name for it, which has the card's number in it: "USB Audio CODEC: USB Audio
# (hw:1,0)". portaudio_name in|out CARD_NUMBER, with PORTAUDIO_DEVICES set
portaudio_name() {
local column=3 desc="$PW_IN_DESC" names
[ "$1" = in ] || { column=4; desc="$PW_OUT_DESC"; }
names="$(awk -F'\t' -v c="$column" '$c > 0 { print $1 }' <<< "$PORTAUDIO_DEVICES")"
if [ -n "$desc" ] && [ "$(grep -cxF "$desc" <<< "$names")" -eq 1 ]; then
echo "$desc"
elif [ -n "$2" ]; then
grep -F "(hw:$2," <<< "$names" | head -1 | grep .
else
return 1
fi
}
# Whether a device setting names the card radio would set, or the same card
# under the number it had before: may_replace_device CURRENT NEW
may_replace_device() {
is_default_device "$1" || (( FORCE )) ||
{ [[ "$2" == *"(hw:"* ]] && [[ "$1" == "${2%(hw:*}(hw:"*")" ]]; }
}
# not1mm: rig control through rigctld, unless it uses flrig, TCI or another
# rigctld already, and the radio's sound card for its voice keyer.
# configure_not1mm CARD_NUMBER
@@ -845,20 +913,18 @@ configure_not1mm() {
(( ! set_rig )) || SAID+=("rig control through rigctld")
if [ -n "$1" ]; then
if device="$(not1mm_device "$1")"; then
if device="$(portaudio_name out "$1")"; then
current="$(jq -r '.sounddevice // ""' "$NOT1MM_CONF")"
if [ "$current" = "$device" ]; then
:
elif is_default_device "$current" || (( FORCE )) ||
# The same card under the number it had before
{ [[ "$device" == *"(hw:"* ]] && [[ "$current" == "${device%(hw:*}(hw:"*")" ]]; }; then
elif may_replace_device "$current" "$device"; then
set_sound=1
SAID+=("voice keyer on \"$device\"")
else
LEFT+=("its sound card ($current)")
fi
else
SAID+=("choose its sound card yourself: its sounddevice library doesn't list the radio's")
SAID+=("choose its sound card yourself: PortAudio doesn't list the radio's")
fi
fi
@@ -1234,6 +1300,7 @@ configure() {
card_number="$(card_of "$radio")"
card_number="${card_number#card}"
find_pipewire_nodes "$card_number" && pipewire=1
PORTAUDIO_DEVICES="$(portaudio_devices)" || PORTAUDIO_DEVICES=""
echo "Setting up the $name (Hamlib model $model), on $port at $baud baud"
echo
@@ -1256,7 +1323,7 @@ configure() {
report JS8Call "not installed"
fi
configure_pat
configure_fldigi
configure_fldigi "$card_number"
configure_direwolf "$card"
configure_not1mm "$card_number"
configure_qlog
@@ -1270,9 +1337,9 @@ configure() {
if [ -z "$card" ]; then
echo "No sound card was found with the radio: choose the one it's connected to in each program yourself."
elif (( pipewire )); then
echo "Choose the radio's sound card yourself in fldigi and POTACAT, which name it in ways radio can't: it's \"$PW_OUT_DESC\" ($card)."
echo "Choose the radio's sound card yourself in POTACAT, which names it in a way radio can't: it's \"$PW_OUT_DESC\" ($card)."
else
echo "PipeWire didn't list the radio's sound card, $card (\"$(attr "${CARD_USB[$(card_of "$radio")]}" product)\"), so choose it yourself in WSJT-X, JS8Call, fldigi and POTACAT."
echo "PipeWire didn't list the radio's sound card, $card (\"$(attr "${CARD_USB[$(card_of "$radio")]}" product)\"), so choose it yourself in WSJT-X, JS8Call and POTACAT."
fi
[ ${#BACKUPS[@]} -eq 0 ] || { echo "The settings were backed up first, to:"; printf ' %s\n' "${BACKUPS[@]}"; }
}
+71 -22
View File
@@ -93,25 +93,30 @@ pipewire_card() {
properties: {"alsa.card": $n, "device.class": "sound"}}]' > "$FAKE_RADIOS/pw-sinks"
}
# The output devices not1mm's sounddevice lists: sd_outputs NAME... Names
# with (hw:...) are ALSA's; the rest are JACK's, except ALSA's pipewire and default
sd_outputs() {
local name
for name; do
# The sound devices PortAudio lists: pa_devices NAME|INPUTS|OUTPUTS... Names
# with (hw:...) are ALSA's, as are pipewire and default; the rest are JACK's
pa_devices() {
local device name
for device; do
name="${device%%|*}"
case "$name" in
*"(hw:"* | pipewire | default) printf '%s\tALSA\n' "$name" ;;
*) printf '%s\tJACK Audio Connection Kit\n' "$name" ;;
*"(hw:"* | pipewire | default) printf '%s\tALSA\t' "$name" ;;
*) printf '%s\tJACK Audio Connection Kit\t' "$name" ;;
esac
done > "$FAKE_RADIOS/sd-outputs"
device="${device#*|}"
printf '%s\t%s\n' "${device%|*}" "${device#*|}"
done > "$FAKE_RADIOS/pa-devices"
}
# The radio on a port answers the probe with ANSWER ("38400 cat_id 0670")
answers() {
echo "$2" > "$FAKE_RADIOS/$1"
# Only the probe is faked; other Python (QLog's log) runs for real
# The probe and PortAudio's device list are faked; other Python (QLog's
# log, Graywolf's settings) runs for real
stub python3 '
case "$3" in
*TIOCMBIC*) f="$FAKE_RADIOS/${4##*/}"; [ -f "$f" ] && cat "$f"; exit 0 ;;
*Pa_Initialize*) cat "$FAKE_RADIOS/pa-devices" 2> /dev/null; exit 0 ;;
esac
exec "$REAL_PYTHON3" "$@"'
}
@@ -382,11 +387,7 @@ JSON
chmod +x "$HOME/.local/bin/not1mm"
mkdir -p "$HOME/.config/not1mm"
echo '{"mycall": "N0CALL", "userigctld": false, "useflrig": false, "usetci": false, "CAT_ip": "127.0.0.1", "CAT_port": 12345, "sounddevice": "default"}' > "$HOME/.config/not1mm/not1mm.json"
# not1mm's Python, whose sounddevice lists the outputs in $FAKE_RADIOS/sd-outputs
mkdir -p "$HOME/.local/share/uv/tools/not1mm/bin"
printf '#!/bin/bash\ncat "$FAKE_RADIOS/sd-outputs" 2> /dev/null\n' > "$HOME/.local/share/uv/tools/not1mm/bin/python"
chmod +x "$HOME/.local/share/uv/tools/not1mm/bin/python"
sd_outputs "HD-Audio Generic: ALC897 Analog (hw:0,0)" "USB Audio CODEC: USB Audio (hw:1,0)" pipewire default
pa_devices "HD-Audio Generic: ALC897 Analog (hw:0,0)|2|2" "USB Audio CODEC: USB Audio (hw:1,0)|1|2" "pipewire|64|64" "default|64|64"
touch "$FAKE_FLATPAKS/io.github.foldynl.QLog"
qlog_log
touch "$HOME/.local/bin/POTACAT.AppImage" "$HOME/.local/bin/graywolf"
@@ -472,7 +473,7 @@ DIREWOLF_CONF() { echo "$HAMPACK_STATE/conf.d/direwolf.conf"; }
grep -qx "ExecStart=/usr/bin/rigctld -m 3073 -r /dev/serial/by-id/usb-Silicon_Labs_CP2102_USB_to_UART_Bridge_Controller_IC-7300_03001234-if00-port0 -s 38400 -T 127.0.0.1 -t 4532" "$unit"
grep -qx "systemctl --user enable hampack-rigctld" "$STUB_LOG"
grep -qx "systemctl --user restart hampack-rigctld" "$STUB_LOG"
[[ "$output" == *"PipeWire didn't list the radio's sound card, hw:CARD=CODEC (\"USB Audio CODEC\"), so choose it yourself in WSJT-X, JS8Call, fldigi and POTACAT."* ]]
[[ "$output" == *"PipeWire didn't list the radio's sound card, hw:CARD=CODEC (\"USB Audio CODEC\"), so choose it yourself in WSJT-X, JS8Call and POTACAT."* ]]
grep -qx "hamlib=3073" "$HAMPACK_STATE/radio"
grep -qx "card=hw:CARD=CODEC" "$HAMPACK_STATE/radio"
}
@@ -629,7 +630,7 @@ DIREWOLF_CONF() { echo "$HAMPACK_STATE/conf.d/direwolf.conf"; }
configurable
sed -i 's|<CHKUSERIGCATIS>0|<CHKUSERIGCATIS>1|' "$(FLDIGI_XML)"
run bash "$REPO/radio" configure
[[ "$output" == *"fldigi: left alone: it has rig control set up already"* ]]
[[ "$output" == *"fldigi: sound card \"USB Audio CODEC: USB Audio (hw:1,0)\". Left its rig control alone"* ]]
grep -qx "<CHKUSEHAMLIBIS>0</CHKUSEHAMLIBIS>" "$(FLDIGI_XML)"
run bash "$REPO/radio" configure --force
@@ -856,7 +857,7 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
[[ "$output" == *"WSJT-X: rig control through rigctld, PTT by CAT, sound card \"USB Audio CODEC Analog Stereo\""* ]]
grep -qx "SoundInName=alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.mono-fallback" "$(WSJTX_INI)"
grep -qx "SoundOutName=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" "$(WSJTX_INI)"
[[ "$output" == *"Choose the radio's sound card yourself in fldigi and POTACAT, which name it in ways radio can't: it's \"USB Audio CODEC Analog Stereo\" (hw:CARD=CODEC)."* ]]
[[ "$output" == *"Choose the radio's sound card yourself in POTACAT, which names it in a way radio can't: it's \"USB Audio CODEC Analog Stereo\" (hw:CARD=CODEC)."* ]]
run bash "$REPO/radio" configure
[[ "$output" == *"WSJT-X: already set up"* ]]
@@ -934,7 +935,7 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
@test "configure gives not1mm's voice keyer the radio's sound card by PipeWire's name, which doesn't change" {
configurable
pipewire_card 1
sd_outputs "USB Audio CODEC: USB Audio (hw:1,0)" "USB Audio CODEC Analog Stereo" pipewire default
pa_devices "USB Audio CODEC: USB Audio (hw:1,0)|1|2" "USB Audio CODEC Mono|1|0" "USB Audio CODEC Analog Stereo|2|2" "pipewire|64|64" "default|64|64"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: rig control through rigctld, voice keyer on \"USB Audio CODEC Analog Stereo\""* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC Analog Stereo" ]
@@ -951,7 +952,7 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
# Two radios with the same codec: PipeWire's name would match both
pipewire_card 1
sd_outputs "USB Audio CODEC: USB Audio (hw:1,0)" "USB Audio CODEC Analog Stereo" "USB Audio CODEC: USB Audio (hw:2,0)" "USB Audio CODEC Analog Stereo"
pa_devices "USB Audio CODEC: USB Audio (hw:1,0)|1|2" "USB Audio CODEC Analog Stereo|2|2" "USB Audio CODEC: USB Audio (hw:2,0)|1|2" "USB Audio CODEC Analog Stereo|2|2"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: already set up"* ]]
}
@@ -971,10 +972,58 @@ con = sqlite3.connect(sys.argv[1]); con.execute("INSERT INTO ptt_configs (channe
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = "USB Audio CODEC: USB Audio (hw:1,0)" ]
}
@test "configure says when not1mm's sounddevice doesn't list the radio's card" {
@test "configure says when PortAudio doesn't list the radio's card for not1mm" {
configurable
sd_outputs "HD-Audio Generic: ALC897 Analog (hw:0,0)" pipewire default
pa_devices "HD-Audio Generic: ALC897 Analog (hw:0,0)|2|2" "pipewire|64|64" "default|64|64"
run bash "$REPO/radio" configure
[[ "$output" == *"not1mm: rig control through rigctld, choose its sound card yourself: its sounddevice library doesn't list the radio's"* ]]
[[ "$output" == *"not1mm: rig control through rigctld, choose its sound card yourself: PortAudio doesn't list the radio's"* ]]
[ "$(jq -r .sounddevice "$(NOT1MM_JSON)")" = default ]
}
@test "configure gives fldigi the radio's sound card through PortAudio, by PipeWire's names" {
configurable
pipewire_card 1
pa_devices "USB Audio CODEC: USB Audio (hw:1,0)|1|2" "USB Audio CODEC Mono|1|0" "USB Audio CODEC Analog Stereo|2|2" "default|64|64"
run bash "$REPO/radio" configure
[[ "$output" == *"fldigi: rig control through rigctld, PTT by Hamlib, sound card \"USB Audio CODEC Analog Stereo\""* ]]
grep -qx "<AUDIOIO>1</AUDIOIO>" "$(FLDIGI_XML)"
grep -qx "<PORTINDEVICE>USB Audio CODEC Mono</PORTINDEVICE>" "$(FLDIGI_XML)"
grep -qx "<PORTOUTDEVICE>USB Audio CODEC Analog Stereo</PORTOUTDEVICE>" "$(FLDIGI_XML)"
grep -qx "<PORTININDEX>-1</PORTININDEX>" "$(FLDIGI_XML)"
run bash "$REPO/radio" configure
[[ "$output" == *"fldigi: already set up"* ]]
}
@test "configure gives fldigi ALSA's names without PipeWire, and replaces defaults and old numbers only" {
configurable
sed -i 's|</FLDIGI_DEFS>|<AUDIOIO>1</AUDIOIO>\n<PORTINDEVICE>default</PORTINDEVICE>\n<PORTOUTDEVICE>USB Audio CODEC: USB Audio (hw:4,0)</PORTOUTDEVICE>\n</FLDIGI_DEFS>|' "$(FLDIGI_XML)"
run bash "$REPO/radio" configure
grep -qx "<PORTINDEVICE>USB Audio CODEC: USB Audio (hw:1,0)</PORTINDEVICE>" "$(FLDIGI_XML)"
grep -qx "<PORTOUTDEVICE>USB Audio CODEC: USB Audio (hw:1,0)</PORTOUTDEVICE>" "$(FLDIGI_XML)"
[ "$(grep -c '<PORTOUTDEVICE>' "$(FLDIGI_XML)")" -eq 1 ]
sed -i 's|<PORTOUTDEVICE>.*|<PORTOUTDEVICE>HD-Audio Generic: ALC897 Analog (hw:0,0)</PORTOUTDEVICE>|' "$(FLDIGI_XML)"
run bash "$REPO/radio" configure
[[ "$output" == *"fldigi: Left its sound card alone"* ]]
grep -qx "<PORTOUTDEVICE>HD-Audio Generic: ALC897 Analog (hw:0,0)</PORTOUTDEVICE>" "$(FLDIGI_XML)"
run bash "$REPO/radio" configure --force
grep -qx "<PORTOUTDEVICE>USB Audio CODEC: USB Audio (hw:1,0)</PORTOUTDEVICE>" "$(FLDIGI_XML)"
}
@test "configure leaves fldigi on PulseAudio unless --force" {
configurable
sed -i 's|</FLDIGI_DEFS>|<AUDIOIO>2</AUDIOIO>\n</FLDIGI_DEFS>|' "$(FLDIGI_XML)"
run bash "$REPO/radio" configure
[[ "$output" == *"fldigi: rig control through rigctld, PTT by Hamlib. Left its sound card alone"* ]]
grep -qx "<AUDIOIO>2</AUDIOIO>" "$(FLDIGI_XML)"
run bash "$REPO/radio" configure --force
grep -qx "<AUDIOIO>1</AUDIOIO>" "$(FLDIGI_XML)"
}
@test "the PortAudio device list runs against the real library" {
# Whatever devices this machine has (none, in CI), it lists them or fails cleanly
run bash -c 'source <(sed -n "/^portaudio_devices() {/,/^}/p" "$1"); portaudio_devices' _ "$REPO/radio"
[ "$status" -eq 0 ] || [ "$status" -eq 1 ]
[[ -z "$output" ]] || [[ "$(head -1 <<< "$output")" == *$'\t'*$'\t'*$'\t'* ]]
}