From b6361ec0800a83ac3dd6321ed1353adf05648616 Mon Sep 17 00:00:00 2001 From: Mute Date: Mon, 17 Aug 2026 06:46:43 +0000 Subject: [PATCH] Revert "fix click: 5ms fade-out from last sample to zero before silence padding" This reverts commit 84474731e7693c4ba1afed6bca7aeed8a66eb9ba. --- Robovoice.App/AudioOutput.cs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/Robovoice.App/AudioOutput.cs b/Robovoice.App/AudioOutput.cs index 33a23a5..72c14e0 100644 --- a/Robovoice.App/AudioOutput.cs +++ b/Robovoice.App/AudioOutput.cs @@ -8,7 +8,6 @@ internal sealed class AudioOutput : IDisposable private BufferedWaveProvider? _bufferProvider; private int _sampleRate; private string _deviceName = string.Empty; - private float _lastSample; private bool _disposed; public Action? Log { get; set; } @@ -19,7 +18,6 @@ internal sealed class AudioOutput : IDisposable _sampleRate = sampleRate; _deviceName = deviceName ?? string.Empty; - _lastSample = 0f; Stop(); @@ -44,9 +42,6 @@ internal sealed class AudioOutput : IDisposable ObjectDisposedException.ThrowIf(_disposed, this); if (_bufferProvider is null) return; - if (samples.Length > 0) - _lastSample = samples[^1]; - byte[] bytes = new byte[samples.Length * sizeof(float)]; Buffer.BlockCopy(samples, 0, bytes, 0, bytes.Length); _bufferProvider.AddSamples(bytes, 0, bytes.Length); @@ -57,21 +52,8 @@ internal sealed class AudioOutput : IDisposable ObjectDisposedException.ThrowIf(_disposed, this); if (_bufferProvider is null || _sampleRate == 0) return; - // Fade out from last sample to zero over 5ms to avoid click - int fadeSamples = (int)(_sampleRate * 0.005); - float[] fade = new float[fadeSamples]; - for (int i = 0; i < fadeSamples; i++) - { - float t = (float)i / fadeSamples; - fade[i] = _lastSample * (1f - t); - } - WriteSamples(fade); - - // Then 500ms of silence to let NAudio drain int padSamples = (int)(_sampleRate * 0.5); WriteSamples(new float[padSamples]); - - _lastSample = 0f; } private void OnPlaybackStopped(object? sender, StoppedEventArgs e) @@ -89,7 +71,6 @@ internal sealed class AudioOutput : IDisposable } _bufferProvider?.ClearBuffer(); _bufferProvider = null; - _lastSample = 0f; } private static int FindDevice(string? deviceName)