From ca9c70eededc690d6b03cc07f9fdf205170f0656 Mon Sep 17 00:00:00 2001 From: Steve John Date: Mon, 15 Jul 2024 11:55:49 +0100 Subject: [PATCH] Centred --- src/Zen.Desktop.Host/Features/WaveVisualiser.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Zen.Desktop.Host/Features/WaveVisualiser.cs b/src/Zen.Desktop.Host/Features/WaveVisualiser.cs index a1c6ce1a..bbd59a0b 100644 --- a/src/Zen.Desktop.Host/Features/WaveVisualiser.cs +++ b/src/Zen.Desktop.Host/Features/WaveVisualiser.cs @@ -149,8 +149,22 @@ private void CentreChannel(float[] buffer) maxPos = i; } } + + var min = float.MaxValue; + + var minPos = int.MinValue; + + for (var i = maxPos; i < BufferSize; i++) + { + if (buffer[i] < min) + { + min = buffer[i]; - var startPos = BufferSize / 2 + maxPos; + minPos = i; + } + } + + var startPos = BufferSize / 2 + maxPos - (maxPos - minPos) / 2; for (var i = 0; i < BufferSize; i++) {