merge: TCI audio — receive, transmit, and the voice keyer over the CAT link
A SunSDR carries its audio on the same WebSocket as its commands, so
OpsLog can take it directly: no virtual cable, no second sound card, no
Windows mixer between the recording and the air. The radio appears as a
device in both audio lists and can be chosen for either direction.
Everything here was settled on real hardware over one evening, and none of
it was guessable from the documentation:
- The receive stream answers format=3 for four-byte floats, so the
sample width is derived from the frame rather than trusted from the
field.
- The radio asks for transmit audio only when the transmission is the
CLIENT'S, and only when its transmit audio source is TCI rather than
the microphone.
- The chrono is a REQUEST, not a clock: no payload, carrying the size it
wants, 47 times a second. Audio goes out in answer to it and never on
a timer of our own — a timer was the first attempt and all 234 frames
of it were ignored.
Confirmed: a clean test recording, and 80 W out of a 1 kHz tone.
This commit is contained in:
@@ -8350,8 +8350,49 @@ type AudioSettings struct {
|
||||
|
||||
// ListAudioInputDevices / ListAudioOutputDevices enumerate WASAPI endpoints
|
||||
// for the device dropdowns.
|
||||
func (a *App) ListAudioInputDevices() ([]audio.Device, error) { return audio.ListInputDevices() }
|
||||
func (a *App) ListAudioOutputDevices() ([]audio.Device, error) { return audio.ListOutputDevices() }
|
||||
// ListAudioInputDevices lists the microphones and line inputs, plus THE RADIO
|
||||
// when the CAT link carries its receive audio.
|
||||
//
|
||||
// Same reasoning as the output list: over TCI there is no sound device for
|
||||
// Windows to show, so without this the one correct answer to "where does the
|
||||
// received audio come from" could not be chosen at all.
|
||||
func (a *App) ListAudioInputDevices() ([]audio.Device, error) {
|
||||
devs, err := audio.ListInputDevices()
|
||||
if err != nil {
|
||||
return devs, err
|
||||
}
|
||||
if a.tciAudioAvailable() {
|
||||
devs = append([]audio.Device{{ID: audio.NetworkDeviceID, Name: "Radio (TCI network audio)"}}, devs...)
|
||||
}
|
||||
return devs, nil
|
||||
}
|
||||
|
||||
// tciAudioAvailable says whether the active CAT backend is a radio that streams
|
||||
// its audio over the CAT link.
|
||||
func (a *App) tciAudioAvailable() bool {
|
||||
if a.cat == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := a.cat.TCIAudioState()
|
||||
return ok
|
||||
}
|
||||
|
||||
// ListAudioOutputDevices lists the sound cards, plus THE RADIO ITSELF when the
|
||||
// CAT link can carry transmit audio.
|
||||
//
|
||||
// Offered only while it is actually available, and named as a radio rather than
|
||||
// as a protocol: an operator choosing where their voice goes is picking between
|
||||
// "my sound card" and "the radio", not between WASAPI and TCI.
|
||||
func (a *App) ListAudioOutputDevices() ([]audio.Device, error) {
|
||||
devs, err := audio.ListOutputDevices()
|
||||
if err != nil {
|
||||
return devs, err
|
||||
}
|
||||
if audio.NetworkPlayerReady() {
|
||||
devs = append([]audio.Device{{ID: audio.NetworkDeviceID, Name: "Radio (TCI network audio)"}}, devs...)
|
||||
}
|
||||
return devs, nil
|
||||
}
|
||||
|
||||
// GetAudioSettings returns the stored audio config (preroll defaults to 8s).
|
||||
func (a *App) GetAudioSettings() (AudioSettings, error) {
|
||||
@@ -8453,6 +8494,15 @@ func (a *App) SaveAudioSettings(s AudioSettings) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Choosing the radio as the receive device opens its stream, and choosing
|
||||
// anything else closes it. Done HERE rather than left to the next restart:
|
||||
// a device chosen in a dropdown that only takes effect after a relaunch
|
||||
// reads as a device that does not work.
|
||||
if s.FromRadio == audio.NetworkDeviceID {
|
||||
a.startTCIRecording()
|
||||
} else if a.tciAudioAvailable() && a.settingOr(keyTCIRecAudio, "") != "1" {
|
||||
_ = a.cat.TCIAudioDo(func(t cat.TCIAudioController) error { return t.StopTCIAudio() })
|
||||
}
|
||||
// Apply device/preroll/enable changes to the running recorder.
|
||||
a.startQSORecorderIfEnabled()
|
||||
// And to a monitor ALREADY RUNNING: the operator is listening while they
|
||||
@@ -8497,7 +8547,7 @@ func (a *App) startQSORecorderIfEnabled() {
|
||||
// nothing right to point at. The stream is pushed into the recorder instead
|
||||
// — same samples, no sound card in the middle, and no virtual cable to set up.
|
||||
from := cfg.FromRadio
|
||||
a.qsoRecPushed = a.icomNetAudioActive()
|
||||
a.qsoRecPushed = a.icomNetAudioActive() || cfg.FromRadio == audio.NetworkDeviceID
|
||||
if a.qsoRecPushed {
|
||||
from = audio.PushedSource
|
||||
}
|
||||
@@ -15178,6 +15228,12 @@ func (a *App) reloadCAT() {
|
||||
} else {
|
||||
a.catSig = sig
|
||||
}
|
||||
// Withdraw the radio as an audio output before deciding anything else. The
|
||||
// TCI case below puts it back; every other backend, and a CAT link turned
|
||||
// off entirely, leaves it withdrawn — a voice keyer that still lists a radio
|
||||
// it can no longer reach would play a message to nowhere, and the operator
|
||||
// hears their own PTT click and assumes it went out.
|
||||
a.installTCITXPlayer(false)
|
||||
if !s.Enabled {
|
||||
a.cat.Stop()
|
||||
return
|
||||
@@ -15300,7 +15356,14 @@ func (a *App) reloadCAT() {
|
||||
a.cat.Start(cat.NewIcomNet(s.IcomNetHost, s.IcomNetUser, s.IcomNetPass, s.IcomAddr, s.DigitalDefault, audioSink))
|
||||
case "tci":
|
||||
// Expert Electronics TCI (WebSocket) — SunSDR / ExpertSDR2, or any
|
||||
// TCI-compatible server.
|
||||
// TCI-compatible server. The receive audio rides the same socket, so
|
||||
// the QSO recorder can take it without a virtual cable — see
|
||||
// app_tci_rec.go. Armed after the backend is up, since it is the
|
||||
// backend that carries the stream.
|
||||
defer a.startTCIRecording()
|
||||
// And the other direction: the voice keyer can send its messages over
|
||||
// the same link — see app_tci_dvk.go.
|
||||
defer a.installTCITXPlayer(true)
|
||||
tb := cat.NewTCI(s.TCIHost, s.TCIPort, s.DigitalDefault, s.TCISpots)
|
||||
// Clicking one of our spots on the ExpertSDR panorama fills the entry form.
|
||||
tb.OnSpotClick = func(call string, hz int64) {
|
||||
|
||||
Reference in New Issue
Block a user