diff --git a/audio/agc.go b/audio/agc.go index f4ca407..9dc2119 100644 --- a/audio/agc.go +++ b/audio/agc.go @@ -21,16 +21,16 @@ type AGC struct { // NewAGC creates a new AGC processor with sensible defaults for voice func NewAGC() *AGC { return &AGC{ - targetLevel: 0.18, // Target 18% of max amplitude (balanced level) - maxGain: 8.0, // Maximum 8x gain (about 18dB) - minGain: 0.1, // Minimum 0.1x gain (-20dB) - attackTime: 0.005, // Fast attack (5ms) - releaseTime: 0.1, // Slower release (100ms) + targetLevel: 0.12, // Target 12% of max amplitude (conservative level) + maxGain: 4.0, // Maximum 4x gain (about 12dB) + minGain: 0.25, // Minimum 0.25x gain (-12dB) + attackTime: 0.008, // Fast attack (8ms) + releaseTime: 0.15, // Slower release (150ms) currentGain: 1.0, // Start with unity gain envelope: 0.0, // Start with zero envelope enabled: true, // Enable by default - compThreshold: 0.7, // Compress signals above 70% - compRatio: 3.0, // 3:1 compression ratio + compThreshold: 0.85, // Compress signals above 85% + compRatio: 2.0, // 2:1 compression ratio (gentler) } } @@ -106,10 +106,10 @@ func (agc *AGC) ProcessSamples(samples []int16) { } // Soft limiting to prevent clipping - if processed > 0.90 { - processed = 0.90 + (processed-0.90)*0.1 - } else if processed < -0.90 { - processed = -0.90 + (processed+0.90)*0.1 + if processed > 0.95 { + processed = 0.95 + (processed-0.95)*0.2 + } else if processed < -0.95 { + processed = -0.95 + (processed+0.95)*0.2 } // Convert back to int16