@@ -333,53 +333,64 @@ def reverberation_time_eyring(
333333 return reverberation_time
334334
335335
336- def calculate_sabine_reverberation_time (surfaces , alphas , volume ):
337- """Calculate the reverberation time using Sabine's equation.
336+ def reverberation_time_sabine (
337+ volume : float ,
338+ surface_area : float ,
339+ mean_absorption : Union [float , np .ndarray ],
340+ speed_of_sound : float = 343.4 ,
341+ ) -> np .ndarray :
342+ r"""
343+ Calculate the reverberation time in rooms as defined by Wallace Sabine.
338344
339- Calculation according to [#]_.
345+ The reverberation time is calculated according to Ref. [#]_ as
346+
347+ .. math::
348+ T_{60} = \frac{24 \cdot \ln(10)}{c}
349+ \cdot \frac{V}{S\tilde{\alpha}}
350+
351+ where :math:`V` is the room volume, :math:`S` is the total surface area
352+ of the room, :math:`\tilde{\alpha}` is the average absorption
353+ coefficient of the room surfaces, and :math:`c` is the speed of sound.
340354
341355 Parameters
342356 ----------
343- surfaces : ndarray, double
344- Surface areas of all surfaces in the room in square meters.
345- alphas : ndarray, double
346- Absorption coefficients corresponding to each surface
347- volume : double
348- Room volume in cubic meters
349-
350- The shape of `surfaces` and `alphas` must match.
357+ surface_area : float
358+ Total surface area of the room in :math:`\mathrm{m}^2`.
359+ mean_absorption : float, numpy.ndarray
360+ Average absorption coefficient of room surfaces between 0 and 1. If
361+ an array is passed, the reverberation time is calculated for each value
362+ in the array.
363+ volume : float
364+ Room volume in :math:`\mathrm{m}^3`.
365+ speed_of_sound : float
366+ Speed of sound in m/s. Default is 343.4 m/s, which corresponds to the
367+ speed of sound in air at 20 °C.
351368
352369 Returns
353370 -------
354- reverberation_time_sabine : double
355- The value of calculated reverberation time in seconds
371+ numpy.ndarray
372+ Reverberation time in seconds.
356373
357374 References
358375 ----------
359376 .. [#] H. Kuttruff, Room acoustics, 4th Ed. Taylor & Francis, 2009.
360377
361378 """
362- surfaces = np .asarray (surfaces )
363- alphas = np .asarray (alphas )
364-
365- if alphas .shape != surfaces .shape :
366- raise ValueError ("Size of alphas and surfaces " \
367- "ndarray sizes must match." )
368379
369- if np .any (alphas ) < 0 or np .any (alphas > 1 ):
370- raise ValueError ("Absorption coefficient values must " \
371- f"be in range [0, 1]. Got { alphas } ." )
372- if np .any (surfaces < 0 ):
373- raise ValueError ("Surface areas cannot " \
374- f"be negative. Got { surfaces } ." )
375- if volume < 0 :
376- raise ValueError (f"Volume cannot be negative. Got { volume } ." )
380+ if speed_of_sound <= 0 :
381+ raise ValueError ("Speed of sound should be larger than 0" )
382+ if volume <= 0 :
383+ raise ValueError ("Volume should be larger than 0" )
384+ if surface_area <= 0 :
385+ raise ValueError ("Surface area should be larger than 0" )
377386
378- absorption_area = np .sum (surfaces * alphas )
387+ mean_absorption = np .asarray (mean_absorption )
388+ if np .any (mean_absorption < 0 ) or np .any (mean_absorption > 1 ):
389+ raise ValueError ("mean_absorption should be between 0 and 1" )
379390
380- if absorption_area == 0 :
381- raise ZeroDivisionError ("Absorption area should be positive." )
391+ factor = 24 * np .log (10 ) / speed_of_sound
382392
383- reverberation_time_sabine = 0.161 * volume / (absorption_area )
393+ with np .errstate (divide = 'ignore' ):
394+ reverberation_time = factor * volume / (surface_area * mean_absorption )
384395
385- return reverberation_time_sabine
396+ return reverberation_time
0 commit comments