Add --tone-test mode: 440 Hz Opus tone + incoming audio capture

Adds a --tone-test flag that bypasses all OpenAL/soundcard
initialization and instead:

- Generates a 440 Hz sine wave at 48kHz mono, encodes it via Opus,
  and sends it to the Mumble server.

- Saves all incoming decoded audio to a raw PCM file (s16le,
  stereo, 48kHz) specified by --tone-out (default: incoming.pcm).

Useful for end-to-end testing of the Opus encode/decode pipeline
and Mumble transport without requiring physical audio hardware.

Usage:
  barnard --server HOST --tone-test --tone-out /tmp/in.pcm

  ffplay -f s16le -ar 48000 -ac 2 incoming.pcm
This commit is contained in:
Brandon McGinty (deepseek)
2026-08-09 00:19:41 -04:00
committed by Brandon McGinty
parent b2a1d2f846
commit 29be821155
4 changed files with 206 additions and 6 deletions
+15 -1
View File
@@ -63,6 +63,12 @@ type Barnard struct {
FileStream *fileplayback.Player
FileStreamMutex sync.Mutex
// Added for tone test mode (bypasses all soundcard/OpenAL)
ToneTest bool
ToneTestOutput string
toneTestStop chan struct{}
toneTestSaver *AudioFileSaver
// Added for recording
RecordingMutex sync.Mutex
Recorder *recording.Recorder
@@ -80,7 +86,15 @@ func (b *Barnard) StopTransmission() {
b.Notify("micdown", "me", "")
b.Tx = false
b.UpdateGeneralStatus(" Idle ", false)
b.Stream.StopSource()
if b.ToneTest {
// Stop the tone generator.
if b.toneTestStop != nil {
close(b.toneTestStop)
b.toneTestStop = nil
}
} else if b.Stream != nil {
b.Stream.StopSource()
}
}
}