From d59d3046165d3787f7dd5c43e6c28a4611441e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz-Guerra=20Aparicio?= Date: Mon, 5 Jul 2021 09:14:10 +0200 Subject: [PATCH] Fixing the bug when the maximum of abs_weights is not 1 Fixing the bug reported by @Nelsonvon in #22 related to the normalization of abs_weights in the function beta_SabineEstimation --- gpuRIR/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpuRIR/__init__.py b/gpuRIR/__init__.py index 6e5e4e9..2c5adf4 100644 --- a/gpuRIR/__init__.py +++ b/gpuRIR/__init__.py @@ -41,7 +41,6 @@ def beta_SabineEstimation(room_sz, T60, abs_weights=[1.0]*6): ''' def t60error(x, T60, room_sz, abs_weights): - abs_weights /= np.array(abs_weights).max() alpha = x * abs_weights Sa = (alpha[0]+alpha[1]) * room_sz[1]*room_sz[2] + \ (alpha[2]+alpha[3]) * room_sz[0]*room_sz[2] + \ @@ -50,6 +49,7 @@ def t60error(x, T60, room_sz, abs_weights): if Sa == 0: return T60 - 0 # Anechoic chamber return abs(T60 - 0.161 * V / Sa) # Sabine's formula + abs_weights /= np.array(abs_weights).max() result = minimize(t60error, 0.5, args=(T60, room_sz, abs_weights), bounds=[[0, 1]]) return np.sqrt(1 - result.x * abs_weights).astype(np.float32)