add a tone test mode that bypasses the soundcard
Add -tone-test to transmit a generated 440 Hz Opus tone and save incoming audio to the file named by -tone-out. Diagnosing an audio problem previously required a working capture and playback device, which is exactly what is in question. This mode opens no OpenAL device at all, so the network and codec path can be tested on a machine with no sound hardware. Open the capture file before starting the generator. Starting transmission first left a tone goroutine running with nowhere to write when the path was unusable. Refuse file playback while in tone test mode, and ignore the microphone volume keys. Both operate on a stream that does not exist here. Stop the generator and detach the file saver on disconnect. A reconnect otherwise attached a second saver to the same file. Add -auto-transmit to key the microphone as soon as the connection is up. Useful for a bot or a monitoring client that should never need a keypress. It runs from both the connect event and the point where the audio stream is created, because the server's welcome arrives before the stream exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
17a4662c6c
commit
ecca0a63ed
@@ -245,6 +245,10 @@ func (b *Barnard) CommandPlayFile(ui *uiterm.Ui, cmd string) {
|
||||
b.AddOutputLine("Not connected to server")
|
||||
return
|
||||
}
|
||||
if b.ToneTest {
|
||||
b.AddOutputLine("File playback is unavailable in tone test mode")
|
||||
return
|
||||
}
|
||||
|
||||
b.FileStreamMutex.Lock()
|
||||
defer b.FileStreamMutex.Unlock()
|
||||
@@ -319,7 +323,14 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
||||
b.Notify("micdown", "me", "")
|
||||
b.Tx = false
|
||||
b.UpdateGeneralStatus(" Idle ", false)
|
||||
b.Stream.StopSource()
|
||||
if b.ToneTest {
|
||||
if b.toneTestStop != nil {
|
||||
close(b.toneTestStop)
|
||||
b.toneTestStop = nil
|
||||
}
|
||||
} else {
|
||||
b.Stream.StopSource()
|
||||
}
|
||||
} else if b.Connected == false {
|
||||
b.Notify("error", "me", "no tx while disconnected")
|
||||
b.Tx = false
|
||||
@@ -331,18 +342,28 @@ func (b *Barnard) setTransmit(ui *uiterm.Ui, val int) {
|
||||
b.UpdateGeneralStatus("cannot transmit in muted channel", true)
|
||||
} else {
|
||||
b.Tx = true
|
||||
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
||||
if err != nil {
|
||||
b.Notify("error", "me", err.Error())
|
||||
b.UpdateGeneralStatus(err.Error(), true)
|
||||
} else {
|
||||
if b.ToneTest {
|
||||
b.toneTestStop = make(chan struct{})
|
||||
go StartToneGenerator(b.Client, b.toneTestStop)
|
||||
b.Notify("micup", "me", "")
|
||||
b.UpdateGeneralStatus(" Tx ", true)
|
||||
} else {
|
||||
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
|
||||
if err != nil {
|
||||
b.Notify("error", "me", err.Error())
|
||||
b.UpdateGeneralStatus(err.Error(), true)
|
||||
} else {
|
||||
b.Notify("micup", "me", "")
|
||||
b.UpdateGeneralStatus(" Tx ", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if b.ToneTest {
|
||||
return
|
||||
}
|
||||
b.Stream.SetMicVolume(-0.1, true)
|
||||
b.UserConfig.SetMicVolume(b.Stream.GetMicVolume())
|
||||
if err := b.UserConfig.SaveConfig(); err != nil {
|
||||
@@ -351,6 +372,9 @@ func (b *Barnard) OnMicVolumeDown(ui *uiterm.Ui, key uiterm.Key) {
|
||||
}
|
||||
|
||||
func (b *Barnard) OnMicVolumeUp(ui *uiterm.Ui, key uiterm.Key) {
|
||||
if b.ToneTest {
|
||||
return
|
||||
}
|
||||
b.Stream.SetMicVolume(0.1, true)
|
||||
b.UserConfig.SetMicVolume(b.Stream.GetMicVolume())
|
||||
if err := b.UserConfig.SaveConfig(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user