initOptions()

in lex-web-ui/src/lib/lex/recorder.js [158:217]


  initOptions(options = {}) {
    // TODO break this into functions, avoid side-effects, break into this.options.*
    if (options.preset) {
      Object.assign(options, this._getPresetOptions(options.preset));
    }

    this.mimeType = options.mimeType || 'audio/wav';

    this.recordingTimeMax = options.recordingTimeMax || 8;
    this.recordingTimeMin = options.recordingTimeMin || 2;
    this.recordingTimeMinAutoIncrease =
      (typeof options.recordingTimeMinAutoIncrease !== 'undefined') ?
        !!options.recordingTimeMinAutoIncrease :
        true;

    // speech detection configuration
    this.autoStopRecording =
      (typeof options.autoStopRecording !== 'undefined') ?
        !!options.autoStopRecording :
        true;
    this.quietThreshold = options.quietThreshold || 0.001;
    this.quietTimeMin = options.quietTimeMin || 0.4;
    this.volumeThreshold = options.volumeThreshold || -75;

    // band pass configuration
    this.useBandPass =
      (typeof options.useBandPass !== 'undefined') ?
        !!options.useBandPass :
        true;
    // https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode
    this.bandPassFrequency = options.bandPassFrequency || 4000;
    // Butterworth 0.707 [sqrt(1/2)]  | Chebyshev < 1.414
    this.bandPassQ = options.bandPassQ || 0.707;

    // parameters passed to script processor and also used in encoder
    // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createScriptProcessor
    this.bufferLength = options.bufferLength || 2048;
    this.numChannels = options.numChannels || 1;

    this.requestEchoCancellation =
      (typeof options.requestEchoCancellation !== 'undefined') ?
        !!options.requestEchoCancellation :
        true;

    // automatic mute detection options
    this.useAutoMuteDetect =
      (typeof options.useAutoMuteDetect !== 'undefined') ?
        !!options.useAutoMuteDetect :
        true;
    this.muteThreshold = options.muteThreshold || 1e-7;

    // encoder options
    this.encoderUseTrim =
      (typeof options.encoderUseTrim !== 'undefined') ?
        !!options.encoderUseTrim :
        true;
    this.encoderQuietTrimThreshold =
      options.encoderQuietTrimThreshold || 0.0008;
    this.encoderQuietTrimSlackBack = options.encoderQuietTrimSlackBack || 4000;
  }