src/hoa-renderer.js
function HOARenderer(context, config) {
  this._context = Utils.isAudioContext(context) ?
      context :
      Utils.throw('HOARenderer: Invalid BaseAudioContext.');

  this._config = {
    ambisonicOrder: 3,
    renderingMode: RenderingMode.AMBISONIC,
  };

  if (config && config.ambisonicOrder) {
    if (SupportedAmbisonicOrder.includes(config.ambisonicOrder)) {
      this._config.ambisonicOrder = config.ambisonicOrder;
    } else {
      Utils.log(
          'HOARenderer: Invalid ambisonic order. (got ' +
          config.ambisonicOrder + ') Fallbacks to 3rd-order ambisonic.');
    }
  }

  this._config.numberOfChannels =
      (this._config.ambisonicOrder + 1) * (this._config.ambisonicOrder + 1);
  this._config.numberOfStereoChannels =
      Math.ceil(this._config.numberOfChannels / 2);

  if (config && config.hrirPathList) {
    if (Array.isArray(config.hrirPathList) &&
        config.hrirPathList.length === this._config.numberOfStereoChannels) {
      this._config.pathList = config.hrirPathList;
    } else {
      Utils.throw(
          'HOARenderer: Invalid HRIR URLs. It must be an array with ' +
          this._config.numberOfStereoChannels + ' URLs to HRIR files.' +
          ' (got ' + config.hrirPathList + ')');
    }
  }

  if (config && config.renderingMode) {
    if (Object.values(RenderingMode).includes(config.renderingMode)) {
      this._config.renderingMode = config.renderingMode;
    } else {
      Utils.log(
          'HOARenderer: Invalid rendering mode. (got ' +
          config.renderingMode + ') Fallbacks to "ambisonic".');
    }
  }

  this._buildAudioGraph();

  this._isRendererReady = false;
}
function HOARenderer(context, config) {
  this._context = Utils.isAudioContext(context) ?
      context :
      Utils.throw('HOARenderer: Invalid BaseAudioContext.');

  this._config = {
    ambisonicOrder: 3,
    renderingMode: RenderingMode.AMBISONIC,
  };

  if (config && config.ambisonicOrder) {
    if (SupportedAmbisonicOrder.includes(config.ambisonicOrder)) {
      this._config.ambisonicOrder = config.ambisonicOrder;
    } else {
      Utils.log(
          'HOARenderer: Invalid ambisonic order. (got ' +
          config.ambisonicOrder + ') Fallbacks to 3rd-order ambisonic.');
    }
  }

  this._config.numberOfChannels =
      (this._config.ambisonicOrder + 1) * (this._config.ambisonicOrder + 1);
  this._config.numberOfStereoChannels =
      Math.ceil(this._config.numberOfChannels / 2);

  if (config && config.hrirPathList) {
    if (Array.isArray(config.hrirPathList) &&
        config.hrirPathList.length === this._config.numberOfStereoChannels) {
      this._config.pathList = config.hrirPathList;
    } else {
      Utils.throw(
          'HOARenderer: Invalid HRIR URLs. It must be an array with ' +
          this._config.numberOfStereoChannels + ' URLs to HRIR files.' +
          ' (got ' + config.hrirPathList + ')');
    }
  }

  if (config && config.renderingMode) {
    if (Object.values(RenderingMode).includes(config.renderingMode)) {
      this._config.renderingMode = config.renderingMode;
    } else {
      Utils.log(
          'HOARenderer: Invalid rendering mode. (got ' +
          config.renderingMode + ') Fallbacks to "ambisonic".');
    }
  }

  this._buildAudioGraph();

  this._isRendererReady = false;
}
function HOARenderer ( context , config ) { this . _context = Utils . isAudioContext ( context ) ? context : Utils . throw ( 'HOARenderer: Invalid BaseAudioContext.' ) ; this . _config = { ambisonicOrder : 3 , renderingMode : RenderingMode . AMBISONIC , } ; if ( config && config . ambisonicOrder ) { if ( SupportedAmbisonicOrder . includes ( config . ambisonicOrder ) ) { this . _config . ambisonicOrder = config . ambisonicOrder ; } else { Utils . log ( 'HOARenderer: Invalid ambisonic order. (got ' + config . ambisonicOrder + ') Fallbacks to 3rd-order ambisonic.' ) ; } } this . _config . numberOfChannels = ( this . _config . ambisonicOrder + 1 ) * ( this . _config . ambisonicOrder + 1 ) ; this . _config . numberOfStereoChannels = Math . ceil ( this . _config . numberOfChannels / 2 ) ; if ( config && config . hrirPathList ) { if ( Array . isArray ( config . hrirPathList ) && config . hrirPathList . length === this . _config . numberOfStereoChannels ) { this . _config . pathList = config . hrirPathList ; } else { Utils . throw ( 'HOARenderer: Invalid HRIR URLs. It must be an array with ' + this . _config . numberOfStereoChannels + ' URLs to HRIR files.' + ' (got ' + config . hrirPathList + ')' ) ; } } if ( config && config . renderingMode ) { if ( Object . values ( RenderingMode ) . includes ( config . renderingMode ) ) { this . _config . renderingMode = config . renderingMode ; } else { Utils . log ( 'HOARenderer: Invalid rendering mode. (got ' + config . renderingMode + ') Fallbacks to "ambisonic".' ) ; } } this . _buildAudioGraph ( ) ; this . _isRendererReady = false ; }
Omnitone HOA renderer class. Uses the optimized convolution technique.
@constructor
@param {AudioContext} context - Associated AudioContext.
@param {Object} config
@param {Number} [config.ambisonicOrder=3] - Ambisonic order.
@param {Array} [config.hrirPathList] - A list of paths to HRIR files. It
overrides the internal HRIR list if given.
@param {RenderingMode} [config.renderingMode='ambisonic'] - Rendering mode.
Omnitone HOA renderer class . Uses the optimized convolution technique .