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.
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package main
|
|
|
|
// TCI receive audio — bindings.
|
|
//
|
|
// A SunSDR carries its receive audio on the same WebSocket as its commands, so
|
|
// OpsLog can take it directly instead of asking the operator to install a
|
|
// virtual audio cable and wire ExpertSDR's output into it. This is the first
|
|
// half: RECEIVE only, which is what the QSO recorder and the CW decoder need.
|
|
// Transmit audio (the voice keyer) is the other half and is not here yet — it
|
|
// has to answer the radio's chrono packets at the right pace, and that is worth
|
|
// doing once the receive side has proved the format on a real radio.
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"hamlog/internal/applog"
|
|
"hamlog/internal/cat"
|
|
)
|
|
|
|
// StartTCIAudio opens the receive-audio stream for one receiver.
|
|
//
|
|
// rate 0 means 48 kHz, which is what ExpertSDR streams by default and what the
|
|
// recorder wants anyway.
|
|
func (a *App) StartTCIAudio(rx, rate int) error {
|
|
if a.cat == nil {
|
|
return fmt.Errorf("CAT not initialized")
|
|
}
|
|
applog.Printf("tci: opening the receive-audio stream (rx %d, %d Hz)", rx, rate)
|
|
return a.cat.TCIAudioDo(func(t cat.TCIAudioController) error { return t.StartTCIAudio(rx, rate) })
|
|
}
|
|
|
|
// StopTCIAudio closes it.
|
|
func (a *App) StopTCIAudio() error {
|
|
if a.cat == nil {
|
|
return fmt.Errorf("CAT not initialized")
|
|
}
|
|
applog.Printf("tci: closing the receive-audio stream")
|
|
return a.cat.TCIAudioDo(func(t cat.TCIAudioController) error { return t.StopTCIAudio() })
|
|
}
|
|
|
|
// GetTCIAudioStatus reports what is arriving: the sample rate the radio chose,
|
|
// how much has come in, and the peak level of the last second.
|
|
//
|
|
// The level is the point. "The stream is open" and "audio is arriving" are
|
|
// different claims, and only the second one is worth anything to someone
|
|
// testing this on a radio for the first time.
|
|
func (a *App) GetTCIAudioStatus() cat.TCIAudioStatus {
|
|
if a.cat == nil {
|
|
return cat.TCIAudioStatus{}
|
|
}
|
|
st, _ := a.cat.TCIAudioState()
|
|
return st
|
|
}
|