<commit_before>/* global define */
/*jslint bitwise: true */
(function (window) {
  'use strict';

  var IirCoeffs = function () {
    var preCalc = function (params, coeffs) {
      var Q = params.Q,
        Fc = params.Fc,
        Fs = params.Fs;
      var pre = {};
      var w = 2 * Math.PI * Fc / Fs;
      pre.alpha = Math.sin(w) / (2 * Q);
      pre.cw = Math.cos(w);
      pre.a0 = 1 + pre.alpha;
      coeffs.a0 = pre.a0;
      coeffs.a.push((-2 * pre.cw) / pre.a0);
      coeffs.a.push((1 - pre.alpha) / pre.a0);
      return pre;
    };
    var preCalcGain = function (params) {
      var Q = params.Q,
        Fc = params.Fc,
        Fs = params.Fs;
      var pre = {};
      var w = 2 * Math.PI * Fc / Fs;
      pre.alpha = Math.sin(w) / (2 * Q);
      pre.cw = Math.cos(w);
      pre.A = Math.pow(10, params.gain / 40);
      return pre;
    };
    var initCoeffs = function () {
      var coeffs = {};
      coeffs.z = [0, 0];
      coeffs.a = [];
      coeffs.b = [];
      return coeffs;
    };
    var self = {
      lowpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        if (params.preGain) {
          coeffs.k = (1 - p.cw) * 0.5;
          coeffs.b.push(1 / (p.a0));
        } else {
          coeffs.k = 1;
          coeffs.b.push((1 - p.cw) / (2 * p.a0));
        }
        coeffs.b.push(2 * coeffs.b[0]);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      highpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        if (params.preGain) {
          coeffs.k = (1 + p.cw) * 0.5;
          coeffs.b.push(1 / (p.a0));
        } else {
          coeffs.k = 1;
          coeffs.b.push((1 + p.cw) / (2 * p.a0));
        }
        coeffs.b.push(-2 * coeffs.b[0]);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      bandpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        coeffs.k = 1;
        coeffs.b.push(p.alpha * params.Q / p.a0);
        coeffs.b.push(0);
        coeffs.b.push(-coeffs.b[0]);
        return coeffs;
      },
      bandstop: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        coeffs.k = 1;
        coeffs.b.push(1 / p.a0);
        coeffs.b.push(-2 * p.cw / p.a0);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      peak: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        coeffs.a0 = 1 + p.alpha / p.A;
        coeffs.a.push(-2 * p.cw / coeffs.a0);
        coeffs.a.push((1 - p.alpha / p.A) / coeffs.a0);
        coeffs.b.push((1 + p.alpha * p.A) / coeffs.a0);
        coeffs.b.push(-2 * p.cw / coeffs.a0);
        coeffs.b.push((1 - p.alpha * p.A) / coeffs.a0);
        return coeffs;
      },
      lowshelf: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        var sa = 2 * Math.sqrt(p.A) * p.alpha;
        coeffs.a0 = (p.A + 1) + (p.A - 1) * p.cw + sa;
        coeffs.a.push((-2 * ((p.A - 1) + (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.a.push(((p.A + 1) + (p.A - 1) * p.cw - sa) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) - (p.A - 1) * p.cw + sa)) / coeffs.a0);
        coeffs.b.push((2 * p.A * ((p.A - 1) - (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) - (p.A - 1) * p.cw - sa)) / coeffs.a0);
        return coeffs;
      },
      highshelf: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        var sa = 2 * Math.sqrt(p.A) * p.alpha;
        coeffs.a0 = (p.A + 1) - (p.A - 1) * p.cw + sa;
        coeffs.a.push((2 * ((p.A - 1) - (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.a.push(((p.A + 1) - (p.A - 1) * p.cw - sa) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) + (p.A - 1) * p.cw + sa)) / coeffs.a0);
        coeffs.b.push((-2 * p.A * ((p.A - 1) + (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) + (p.A - 1) * p.cw - sa)) / coeffs.a0);
        return coeffs;
      }
    };
    return self;
  };
  if (typeof module === 'object' && module && typeof module.exports === 'object') {
    module.exports = IirCoeffs;
  } else {
    window.IirCoeffs = IirCoeffs;
    if (typeof define === 'function' && define.amd) {
      define(IirCoeffs);
    }
  }
})(window);
<commit_msg>added phaseshift allpass<commit_after>/* global define */
/*jslint bitwise: true */
(function (window) {
  'use strict';

  var IirCoeffs = function () {
    var preCalc = function (params, coeffs) {
      var Q = params.Q,
        Fc = params.Fc,
        Fs = params.Fs;
      var pre = {};
      var w = 2 * Math.PI * Fc / Fs;
      pre.alpha = Math.sin(w) / (2 * Q);
      pre.cw = Math.cos(w);
      pre.a0 = 1 + pre.alpha;
      coeffs.a0 = pre.a0;
      coeffs.a.push((-2 * pre.cw) / pre.a0);
      coeffs.a.push((1 - pre.alpha) / pre.a0);
      return pre;
    };
    var preCalcGain = function (params) {
      var Q = params.Q,
        Fc = params.Fc,
        Fs = params.Fs;
      var pre = {};
      var w = 2 * Math.PI * Fc / Fs;
      pre.alpha = Math.sin(w) / (2 * Q);
      pre.cw = Math.cos(w);
      pre.A = Math.pow(10, params.gain / 40);
      return pre;
    };
    var preBilinear = function (params) {
      var pre = {};
      pre.g = Math.tan(Math.PI * params.Fc / params.Fs);
      pre.d = 1 / params.Q;
      pre.K = 1 / (1 + pre.d * pre.g + pre.g * pre.g);
      if (typeof (params.gain) === 'number') {
        pre.A = Math.pow(10, params.gain / 20);
        if (pre.A < 1) {
          pre.A = 1 / pre.A;
          pre.K = 1 / (1 + Math.sqrt(pre.A) * pre.d * pre.g + pre.A * pre.g * pre.g);
        }
      }
      return pre;
    };
    var initCoeffs = function () {
      var coeffs = {};
      coeffs.z = [0, 0];
      coeffs.a = [];
      coeffs.b = [];
      return coeffs;
    };
    var self = {
      lowpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        if (params.preGain) {
          coeffs.k = (1 - p.cw) * 0.5;
          coeffs.b.push(1 / (p.a0));
        } else {
          coeffs.k = 1;
          coeffs.b.push((1 - p.cw) / (2 * p.a0));
        }
        coeffs.b.push(2 * coeffs.b[0]);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      highpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        if (params.preGain) {
          coeffs.k = (1 + p.cw) * 0.5;
          coeffs.b.push(1 / (p.a0));
        } else {
          coeffs.k = 1;
          coeffs.b.push((1 + p.cw) / (2 * p.a0));
        }
        coeffs.b.push(-2 * coeffs.b[0]);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      bandpass: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        coeffs.k = 1;
        coeffs.b.push(p.alpha * params.Q / p.a0);
        coeffs.b.push(0);
        coeffs.b.push(-coeffs.b[0]);
        return coeffs;
      },
      bandstop: function (params) {
        var coeffs = initCoeffs();
        var p = preCalc(params, coeffs);
        coeffs.k = 1;
        coeffs.b.push(1 / p.a0);
        coeffs.b.push(-2 * p.cw / p.a0);
        coeffs.b.push(coeffs.b[0]);
        return coeffs;
      },
      peak: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        coeffs.a0 = 1 + p.alpha / p.A;
        coeffs.a.push(-2 * p.cw / coeffs.a0);
        coeffs.a.push((1 - p.alpha / p.A) / coeffs.a0);
        coeffs.b.push((1 + p.alpha * p.A) / coeffs.a0);
        coeffs.b.push(-2 * p.cw / coeffs.a0);
        coeffs.b.push((1 - p.alpha * p.A) / coeffs.a0);
        return coeffs;
      },
      lowshelf: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        var sa = 2 * Math.sqrt(p.A) * p.alpha;
        coeffs.a0 = (p.A + 1) + (p.A - 1) * p.cw + sa;
        coeffs.a.push((-2 * ((p.A - 1) + (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.a.push(((p.A + 1) + (p.A - 1) * p.cw - sa) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) - (p.A - 1) * p.cw + sa)) / coeffs.a0);
        coeffs.b.push((2 * p.A * ((p.A - 1) - (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) - (p.A - 1) * p.cw - sa)) / coeffs.a0);
        return coeffs;
      },
      highshelf: function (params) {
        var coeffs = initCoeffs();
        var p = preCalcGain(params);
        coeffs.k = 1;
        var sa = 2 * Math.sqrt(p.A) * p.alpha;
        coeffs.a0 = (p.A + 1) - (p.A - 1) * p.cw + sa;
        coeffs.a.push((2 * ((p.A - 1) - (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.a.push(((p.A + 1) - (p.A - 1) * p.cw - sa) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) + (p.A - 1) * p.cw + sa)) / coeffs.a0);
        coeffs.b.push((-2 * p.A * ((p.A - 1) + (p.A + 1) * p.cw)) / coeffs.a0);
        coeffs.b.push((p.A * ((p.A + 1) + (p.A - 1) * p.cw - sa)) / coeffs.a0);
        return coeffs;
      },
      phaseshift: function (params) {
        var coeffs = initCoeffs();
        var p = preBilinear(params);
        coeffs.k = 1;
        coeffs.a0 = 1;
        coeffs.b.push(p.K * (1 - p.g * p.d + p.g * p.g));
        coeffs.b.push(2 * p.K * (p.g * p.g - 1));
        coeffs.b.push(1);
        coeffs.a.push(coeffs.b[1]);
        coeffs.a.push(coeffs.b[0]);
        return coeffs;
      }
    };
    return self;
  };
  if (typeof module === 'object' && module && typeof module.exports === 'object') {
    module.exports = IirCoeffs;
  } else {
    window.IirCoeffs = IirCoeffs;
    if (typeof define === 'function' && define.amd) {
      define(IirCoeffs);
    }
  }
})(window);

{'fraction_non_alphanumeric': 0.19410692588092346, 'fraction_numerical': 0.024098825435398947, 'mean_word_length': 1.5024068913098556, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3900149', 'n_tokens_mistral': 4239, 'n_tokens_neox': 4285, 'n_words': 834}