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:
co-authored by
Claude Opus 5.5
parent
c2cb2bc2f4
commit
8020cdc061
+71
-22
@@ -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'* ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user