Skip to content

Commit

Permalink
Fixing the bug when the maximum of abs_weights is not 1
Browse files Browse the repository at this point in the history
Fixing the bug reported by @Nelsonvon in #22 related to the normalization of abs_weights in the function beta_SabineEstimation
  • Loading branch information
DavidDiazGuerra authored Jul 5, 2021
1 parent c1279cd commit d59d304
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gpuRIR/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] + \
Expand All @@ -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)

Expand Down

0 comments on commit d59d304

Please sign in to comment.