From a255009cc0061a73e5281d3339bb3c9146ee82c4 Mon Sep 17 00:00:00 2001 From: videogame hacker Date: Tue, 30 May 2023 07:48:13 +0100 Subject: [PATCH] Correct pan law so balance in [0, 1] hardpans --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index bc5a111..9d3da34 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,8 +29,8 @@ fn decode_signal_balance(channel_0: &mut [f32], channel_1: &mut [f32]) { let sig = channel_0[sample_idx]; let balance = channel_1[sample_idx]; - let left = sig * (0.5 * -balance + 1.0); - let right = sig * (0.5 * balance + 1.0); + let left = sig * (1.0 - balance) * 0.5; + let right = sig * (1.0 + balance) * 0.5; channel_0[sample_idx] = left; channel_1[sample_idx] = right;