mirror of https://github.com/jetkvm/kvm.git
fix: Add noise gate to prevent amplifying silence artifacts
Add noise gate threshold at peak > 256 (-42dB) to prevent dynamic gain from amplifying quantization noise and hardware noise floor. This fixes crackling, buzzing, and static-like noise when HDMI audio is at very low volume or during silence. Without the gate, signals below -42dB (peak < 256) would get 8x gain applied, amplifying noise floor to audible levels. Now these signals pass through unmodified, eliminating the artifacts.
This commit is contained in:
parent
5158c89103
commit
04dd37f58f
|
|
@ -496,11 +496,12 @@ retry_read:
|
|||
if (abs_val > peak) peak = abs_val;
|
||||
}
|
||||
|
||||
// Apply gain if signal is weak (below -18dB = 4096) for best quality
|
||||
// Apply gain if signal is weak (below -18dB = 4096) but above noise floor
|
||||
// Noise gate: only apply gain if peak > 256 (below this is likely just noise)
|
||||
// Target: boost to ~50% of range (16384) to improve SNR
|
||||
if (peak > 0 && peak < 4096) {
|
||||
if (peak > 256 && peak < 4096) {
|
||||
float gain = 16384.0f / peak;
|
||||
if (gain > 8.0f) gain = 8.0f; // Max 18dB boost for best quality
|
||||
if (gain > 8.0f) gain = 8.0f; // Max 18dB boost
|
||||
|
||||
// Apply gain with NEON and saturation
|
||||
float32x4_t vgain = vdupq_n_f32(gain);
|
||||
|
|
|
|||
Loading…
Reference in New Issue