feat(tci): receive audio over the TCI WebSocket (experimental)
A SunSDR already carries its receive audio on the same WebSocket as its commands, so a virtual audio cable and a second sound card are two pieces of plumbing an operator installs for no reason. This is the receive half: what the QSO recorder and the CW decoder need. The reader now looks at the frame type. It used to ignore it and split every frame on ';' -- harmless only for as long as no stream was ever opened, since audio bytes would otherwise have been handed to the command parser a hundred times a second. NOTHING HERE IS CONFIRMED ON A RADIO. The header layout comes from the TCI documentation, and the stream-type numbers are exactly the sort of detail a document gets right and a memory of it does not -- so the first forty frames of a session are logged verbatim, and a test bench in Preferences > Audio reports the sample rate the radio chose, the frames arriving and the peak level of the last second. 'The stream is open' and 'audio is arriving' are different claims and only the second is worth anything to whoever tries this first. Transmit (the voice keyer) is the other half and is deliberately absent: it has to answer the radio's chrono packets at the right pace, and that is worth doing once the format is settled on real hardware.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
//go:build windows
|
||||
|
||||
package cat
|
||||
|
||||
import "fmt"
|
||||
|
||||
// TCIAudioController is the receive-audio capability of the TCI backend, kept
|
||||
// as an interface for the same reason as the Flex and Yaesu ones: the host asks
|
||||
// the manager, and a station running something else gets a clear "this backend
|
||||
// does not do that" instead of a nil dereference.
|
||||
type TCIAudioController interface {
|
||||
StartTCIAudio(rx, rate int) error
|
||||
StopTCIAudio() error
|
||||
TCIAudioStatus() TCIAudioStatus
|
||||
}
|
||||
|
||||
// TCIAudioState returns the stream's state, or (zero, false) when the active
|
||||
// backend is not a TCI radio.
|
||||
func (m *Manager) TCIAudioState() (TCIAudioStatus, bool) {
|
||||
m.mu.RLock()
|
||||
b := m.backend
|
||||
m.mu.RUnlock()
|
||||
if tc, ok := b.(TCIAudioController); ok {
|
||||
return tc.TCIAudioStatus(), true
|
||||
}
|
||||
return TCIAudioStatus{}, false
|
||||
}
|
||||
|
||||
// TCIAudioDo dispatches an audio command onto the CAT goroutine, like every
|
||||
// other backend-specific control.
|
||||
func (m *Manager) TCIAudioDo(fn func(TCIAudioController) error) error {
|
||||
return m.exec(func(b Backend) error {
|
||||
tc, ok := b.(TCIAudioController)
|
||||
if !ok {
|
||||
return fmt.Errorf("active CAT backend is not a TCI radio")
|
||||
}
|
||||
return fn(tc)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user