src/room.js
function _getDurationsFromProperties(dimensions, coefficients, speedOfSound) {
  let durations = new Float32Array(Utils.NUMBER_REVERB_FREQUENCY_BANDS);

  // Sanitize inputs.
  dimensions = _sanitizeDimensions(dimensions);
  coefficients = _sanitizeCoefficients(coefficients);
  if (speedOfSound == undefined) {
    speedOfSound = Utils.DEFAULT_SPEED_OF_SOUND;
  }

  // Acoustic constant.
  let k = Utils.TWENTY_FOUR_LOG10 / speedOfSound;

  // Compute volume, skip if room is not present.
  let volume = dimensions.width * dimensions.height * dimensions.depth;
  if (volume < Utils.ROOM_MIN_VOLUME) {
    return durations;
  }

  // Room surface area.
  let leftRightArea = dimensions.width * dimensions.height;
  let floorCeilingArea = dimensions.width * dimensions.depth;
  let frontBackArea = dimensions.depth * dimensions.height;
  let totalArea = 2 * (leftRightArea + floorCeilingArea + frontBackArea);
  for (let i = 0; i < Utils.NUMBER_REVERB_FREQUENCY_BANDS; i++) {
    // Effective absorptive area.
    let absorbtionArea =
      (coefficients.left[i] + coefficients.right[i]) * leftRightArea +
      (coefficients.down[i] + coefficients.up[i]) * floorCeilingArea +
      (coefficients.front[i] + coefficients.back[i]) * frontBackArea;
    let meanAbsorbtionArea = absorbtionArea / totalArea;

    // Compute reverberation using Eyring equation [1].
    // [1] Beranek, Leo L. "Analysis of Sabine and Eyring equations and their
    //     application to concert hall audience and chair absorption." The
    //     Journal of the Acoustical Society of America, Vol. 120, No. 3.
    //     (2006), pp. 1399-1399.
    durations[i] = Utils.ROOM_EYRING_CORRECTION_COEFFICIENT * k * volume /
      (-totalArea * Math.log(1 - meanAbsorbtionArea) + 4 *
      Utils.ROOM_AIR_ABSORPTION_COEFFICIENTS[i] * volume);
  }
  return durations;
}
function _getDurationsFromProperties(dimensions, coefficients, speedOfSound) {
  let durations = new Float32Array(Utils.NUMBER_REVERB_FREQUENCY_BANDS);

  // Sanitize inputs.
  dimensions = _sanitizeDimensions(dimensions);
  coefficients = _sanitizeCoefficients(coefficients);
  if (speedOfSound == undefined) {
    speedOfSound = Utils.DEFAULT_SPEED_OF_SOUND;
  }

  // Acoustic constant.
  let k = Utils.TWENTY_FOUR_LOG10 / speedOfSound;

  // Compute volume, skip if room is not present.
  let volume = dimensions.width * dimensions.height * dimensions.depth;
  if (volume < Utils.ROOM_MIN_VOLUME) {
    return durations;
  }

  // Room surface area.
  let leftRightArea = dimensions.width * dimensions.height;
  let floorCeilingArea = dimensions.width * dimensions.depth;
  let frontBackArea = dimensions.depth * dimensions.height;
  let totalArea = 2 * (leftRightArea + floorCeilingArea + frontBackArea);
  for (let i = 0; i < Utils.NUMBER_REVERB_FREQUENCY_BANDS; i++) {
    // Effective absorptive area.
    let absorbtionArea =
      (coefficients.left[i] + coefficients.right[i]) * leftRightArea +
      (coefficients.down[i] + coefficients.up[i]) * floorCeilingArea +
      (coefficients.front[i] + coefficients.back[i]) * frontBackArea;
    let meanAbsorbtionArea = absorbtionArea / totalArea;

    // Compute reverberation using Eyring equation [1].
    // [1] Beranek, Leo L. "Analysis of Sabine and Eyring equations and their
    //     application to concert hall audience and chair absorption." The
    //     Journal of the Acoustical Society of America, Vol. 120, No. 3.
    //     (2006), pp. 1399-1399.
    durations[i] = Utils.ROOM_EYRING_CORRECTION_COEFFICIENT * k * volume /
      (-totalArea * Math.log(1 - meanAbsorbtionArea) + 4 *
      Utils.ROOM_AIR_ABSORPTION_COEFFICIENTS[i] * volume);
  }
  return durations;
}
function _getDurationsFromProperties ( dimensions , coefficients , speedOfSound ) { let durations = new Float32Array ( Utils . NUMBER_REVERB_FREQUENCY_BANDS ) ; // Sanitize inputs. dimensions = _sanitizeDimensions ( dimensions ) ; coefficients = _sanitizeCoefficients ( coefficients ) ; if ( speedOfSound == undefined ) { speedOfSound = Utils . DEFAULT_SPEED_OF_SOUND ; } // Acoustic constant. let k = Utils . TWENTY_FOUR_LOG10 / speedOfSound ; // Compute volume, skip if room is not present. let volume = dimensions . width * dimensions . height * dimensions . depth ; if ( volume < Utils . ROOM_MIN_VOLUME ) { return durations ; } // Room surface area. let leftRightArea = dimensions . width * dimensions . height ; let floorCeilingArea = dimensions . width * dimensions . depth ; let frontBackArea = dimensions . depth * dimensions . height ; let totalArea = 2 * ( leftRightArea + floorCeilingArea + frontBackArea ) ; for ( let i = 0 ; i < Utils . NUMBER_REVERB_FREQUENCY_BANDS ; i ++ ) { // Effective absorptive area. let absorbtionArea = ( coefficients . left [ i ] + coefficients . right [ i ] ) * leftRightArea + ( coefficients . down [ i ] + coefficients . up [ i ] ) * floorCeilingArea + ( coefficients . front [ i ] + coefficients . back [ i ] ) * frontBackArea ; let meanAbsorbtionArea = absorbtionArea / totalArea ; // Compute reverberation using Eyring equation [1]. // [1] Beranek, Leo L. "Analysis of Sabine and Eyring equations and their //     application to concert hall audience and chair absorption." The //     Journal of the Acoustical Society of America, Vol. 120, No. 3. //     (2006), pp. 1399-1399. durations [ i ] = Utils . ROOM_EYRING_CORRECTION_COEFFICIENT * k * volume / ( - totalArea * Math . log ( 1 - meanAbsorbtionArea ) + 4 * Utils . ROOM_AIR_ABSORPTION_COEFFICIENTS [ i ] * volume ) ; } return durations ; }
Compute frequency-dependent reverb durations.
@param {Utils~RoomDimensions} dimensions
@param {Object} coefficients
@param {Number} speedOfSound
@return {Array}
Compute frequency - dependent reverb durations .