make microphone AGC less aggressive and switchable
Lower the gain ceiling and slow the attack of the automatic gain control. It amplified room noise between words hard enough to be audible as a rising hiss whenever the speaker paused. Add an AGC toggle on F12 and an /agc command. AGC has always been applied unconditionally, which is wrong for a microphone that is already levelled by hardware or by the system mixer. The preference is saved and reapplied on connect, defaulting to on so existing setups are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
17173b779b
commit
cb4f91596e
@@ -111,6 +111,29 @@ func (b *Barnard) OnNoiseSuppressionToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) OnAGCToggle(ui *uiterm.Ui, key uiterm.Key) {
|
||||
enabled := b.toggleAGC()
|
||||
|
||||
if enabled {
|
||||
b.UpdateGeneralStatus("AGC: ON", false)
|
||||
} else {
|
||||
b.UpdateGeneralStatus("AGC: OFF", false)
|
||||
}
|
||||
}
|
||||
|
||||
// toggleAGC flips the saved AGC preference and applies it to the active
|
||||
// stream, returning the new state.
|
||||
func (b *Barnard) toggleAGC() bool {
|
||||
enabled := !b.UserConfig.GetAGCEnabled()
|
||||
if err := b.UserConfig.SetAGCEnabled(enabled); err != nil {
|
||||
b.AddOutputLine("AGC: could not save setting: " + err.Error())
|
||||
}
|
||||
if b.Stream != nil {
|
||||
b.Stream.SetAGCEnabled(enabled)
|
||||
}
|
||||
return enabled
|
||||
}
|
||||
|
||||
func (b *Barnard) UpdateGeneralStatus(text string, notice bool) {
|
||||
b.statusText = text
|
||||
b.statusNotice = notice
|
||||
@@ -175,6 +198,14 @@ func (b *Barnard) CommandNoiseSuppressionToggle(ui *uiterm.Ui, cmd string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) CommandAGCToggle(ui *uiterm.Ui, cmd string) {
|
||||
if b.toggleAGC() {
|
||||
b.AddOutputLine("AGC enabled")
|
||||
} else {
|
||||
b.AddOutputLine("AGC disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Barnard) CommandPlayFile(ui *uiterm.Ui, cmd string) {
|
||||
// cmd contains just the filename part (everything after "/file ")
|
||||
filename := strings.TrimSpace(cmd)
|
||||
@@ -397,6 +428,8 @@ func (b *Barnard) OnTextInput(ui *uiterm.Ui, textbox *uiterm.Textbox, text strin
|
||||
b.CommandStatus(ui, cmdArgs)
|
||||
case "noise":
|
||||
b.CommandNoiseSuppressionToggle(ui, cmdArgs)
|
||||
case "agc":
|
||||
b.CommandAGCToggle(ui, cmdArgs)
|
||||
case "record":
|
||||
b.CommandRecord(ui, cmdArgs)
|
||||
case "admin":
|
||||
@@ -493,6 +526,7 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
||||
b.Ui.AddCommandListener(b.CommandExit, "exit")
|
||||
b.Ui.AddCommandListener(b.CommandStatus, "status")
|
||||
b.Ui.AddCommandListener(b.CommandNoiseSuppressionToggle, "noise")
|
||||
b.Ui.AddCommandListener(b.CommandAGCToggle, "agc")
|
||||
b.Ui.AddCommandListener(b.CommandPlayFile, "file")
|
||||
b.Ui.AddCommandListener(b.CommandStopFile, "stop")
|
||||
b.Ui.AddCommandListener(b.CommandRecord, "record")
|
||||
@@ -502,6 +536,7 @@ func (b *Barnard) OnUiInitialize(ui *uiterm.Ui) {
|
||||
b.Ui.AddKeyListener(b.OnVoiceToggle, b.Hotkeys.Talk)
|
||||
b.Ui.AddKeyListener(b.OnTimestampToggle, b.Hotkeys.ToggleTimestamps)
|
||||
b.Ui.AddKeyListener(b.OnNoiseSuppressionToggle, b.Hotkeys.NoiseSuppressionToggle)
|
||||
b.Ui.AddKeyListener(b.OnAGCToggle, b.Hotkeys.AGCToggle)
|
||||
b.Ui.AddKeyListener(b.OnRecordingToggle, b.Hotkeys.RecordToggle)
|
||||
b.Ui.AddKeyListener(b.OnQuitPress, b.Hotkeys.Exit)
|
||||
b.Ui.AddKeyListener(b.OnScrollOutputUp, b.Hotkeys.ScrollUp)
|
||||
|
||||
Reference in New Issue
Block a user