Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
) {
super(context, model);
this.tunings = { ...Distortion.defaultTunings, ...tunings };
// Boost stage - pre-filtering.
const bandpassParams = calculateBandpass(this.tunings.preFilterRange);
this.preFilter = new BiquadFilterNode(context, {
type: 'bandpass',
Q: bandpassParams.q,
frequency: bandpassParams.fc
});
// Clipping stage.
this.waveSharper = new WaveShaperNode(context, {
oversample: '4x'
});
this.postFilter = new BiquadFilterNode(context, {
type: 'lowpass',
Q: Math.SQRT1_2,
frequency: this.tunings.postFilter
});
// Equalization stage.
if (this.tunings.toneControlType === 'standard') {
this.toneNode = new StandardTone(context, this.tunings.toneRange);
}
if (this.tunings.toneControlType === 'mixed') {
this.toneNode = new MixedTone(context, this.tunings.toneRange);
this.boostNode = new GainNode(context, {
gain: dBToGain(this.tunings.boost)
});
const preRange = this.tunings.preFilterRange;
this.preHighpass = new IIRFilterNode(context, {
...onePoleHighpass(preRange[0], context.sampleRate)
});
this.preLowpass = new IIRFilterNode(context, {
...onePoleLowpass(preRange[1], context.sampleRate)
});
// Double clipping stage.
this.waveSharper1Stage = new WaveShaperNode(context, {
oversample: '4x'
});
this.waveSharper2Stage = new WaveShaperNode(context, {
oversample: '4x'
});
const postRange = this.tunings.postFilterRanges;
this.postLowpass1Stage = new IIRFilterNode(context, {
...onePoleHighpass(postRange[0], context.sampleRate)
});
this.postHighpass1Stage = new IIRFilterNode(context, {
...onePoleLowpass(postRange[1], context.sampleRate)
});
this.postLowpass2Stage = new IIRFilterNode(context, {
const preRange = this.tunings.preFilterRange;
this.preHighpass = new IIRFilterNode(context, {
...onePoleHighpass(preRange[0], context.sampleRate)
});
this.preLowpass = new IIRFilterNode(context, {
...onePoleLowpass(preRange[1], context.sampleRate)
});
// Double clipping stage.
this.waveSharper1Stage = new WaveShaperNode(context, {
oversample: '4x'
});
this.waveSharper2Stage = new WaveShaperNode(context, {
oversample: '4x'
});
const postRange = this.tunings.postFilterRanges;
this.postLowpass1Stage = new IIRFilterNode(context, {
...onePoleHighpass(postRange[0], context.sampleRate)
});
this.postHighpass1Stage = new IIRFilterNode(context, {
...onePoleLowpass(postRange[1], context.sampleRate)
});
this.postLowpass2Stage = new IIRFilterNode(context, {
...onePoleHighpass(postRange[2], context.sampleRate)
});