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:
committed by
Brandon McGinty
parent
b2a1d2f846
commit
29be821155
@@ -17,11 +17,18 @@ func (b *Barnard) start() {
|
||||
b.Config.Attach(gumbleutil.AutoBitrate)
|
||||
b.Config.Attach(b)
|
||||
b.Config.Address = b.Address
|
||||
// test Audio
|
||||
_, err := gumbleopenal.New(b.Client, b.UserConfig.GetInputDevice(), b.UserConfig.GetOutputDevice(), true)
|
||||
if err != nil {
|
||||
b.exitWithError(err)
|
||||
return
|
||||
|
||||
if b.ToneTest {
|
||||
// Tone test mode: skip all OpenAL/soundcard initialization.
|
||||
// We just need a network connection — the tone generator and
|
||||
// file saver are set up in connect().
|
||||
} else {
|
||||
// test Audio
|
||||
_, err := gumbleopenal.New(b.Client, b.UserConfig.GetInputDevice(), b.UserConfig.GetOutputDevice(), true)
|
||||
if err != nil {
|
||||
b.exitWithError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
//connect, not reconnect
|
||||
b.connect(false)
|
||||
@@ -45,6 +52,27 @@ func (b *Barnard) connect(reconnect bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if b.ToneTest {
|
||||
// --- Tone test mode: skip all OpenAL; generate 440 Hz tone
|
||||
// --- and save incoming audio to a file.
|
||||
|
||||
// Start the tone generator goroutine.
|
||||
b.toneTestStop = make(chan struct{})
|
||||
go StartToneGenerator(b.Client, b.toneTestStop)
|
||||
|
||||
// Attach the audio file saver.
|
||||
saver, err := NewAudioFileSaver(b.ToneTestOutput)
|
||||
if err != nil {
|
||||
b.exitWithError(err)
|
||||
return false
|
||||
}
|
||||
b.toneTestSaver = saver
|
||||
b.Client.Config.AttachAudio(saver)
|
||||
|
||||
b.Connected = true
|
||||
return true
|
||||
}
|
||||
|
||||
stream, err := gumbleopenal.New(b.Client, b.UserConfig.GetInputDevice(), b.UserConfig.GetOutputDevice(), false)
|
||||
if err != nil {
|
||||
b.exitWithError(err)
|
||||
@@ -138,6 +166,19 @@ func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||
reason = e.String
|
||||
}
|
||||
b.stopRecordingForDisconnect()
|
||||
|
||||
// Tone test cleanup
|
||||
if b.ToneTest {
|
||||
if b.toneTestStop != nil {
|
||||
close(b.toneTestStop)
|
||||
b.toneTestStop = nil
|
||||
}
|
||||
if b.toneTestSaver != nil {
|
||||
b.toneTestSaver.Stop()
|
||||
b.toneTestSaver = nil
|
||||
}
|
||||
}
|
||||
|
||||
b.Notify("disconnect", "me", reason)
|
||||
if reason == "" {
|
||||
b.AddOutputLine("Disconnected")
|
||||
|
||||
Reference in New Issue
Block a user