Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
// Output stage.
this.levelNode = new GainNode(context);
this.processor = [
this.preFilter,
this.waveSharper,
this.postFilter,
...this.toneNode.nodes,
this.levelNode
];
connectNodes(this.processor);
this.applyDefaults();
}
constructor(
context: AudioContext,
model: string,
protected defaults: ChorusSettings
) {
super(context, model);
this.eqNode = new StandardTone(context);
this.lfo = new LFO(context);
this.delayNode = new DelayNode(context);
this.feedbackNode = new GainNode(context);
this.levelNode = new GainNode(context);
this.processor = [...this.eqNode.nodes, this.delayNode, this.levelNode];
connectNodes(this.processor);
// Feedback loop.
this.delayNode.connect(this.feedbackNode);
this.feedbackNode.connect(this.delayNode);
// LFO setup.
this.lfo.connect(this.delayNode.delayTime);
this.applyDefaults();
}
constructor(context: AudioContext, private type: LFOType = 'sine') {
this.osc = new OscillatorNode(context, {
type: LFO.isAllowedType(type) ? (type as TOscillatorType) : undefined,
frequency: 0.5
});
// Add one to the output signals, making the range [0, 2].
this.offsetNode = new ConstantSourceNode(context, { offset: 1 });
this.offsetNode.start();
// Divide the result by 2, making the range [0, 1].
this.rangeNode = new GainNode(context, { gain: 0.5 });
this.depthNode = new GainNode(context);
// Map the oscillator's output range from [-1, 1] to [0, 1].
this.osc.connect(this.offsetNode.offset as any);
this.offsetNode.connect(this.rangeNode).connect(this.depthNode);
}
constructor(
context: AudioContext,
model: string,
protected defaults: TremoloSettings,
type?: LFOType
) {
super(context, model);
this.lfo = new LFO(context, type);
this.gainNode = new GainNode(context, { gain: 0 });
this.processor = [this.gainNode];
connectNodes(this.processor);
// LFO setup.
this.lfo.connect(this.gainNode.gain);
this.applyDefaults();
}
constructor(context: AudioContext, private type: LFOType = 'sine') {
this.osc = new OscillatorNode(context, {
type: LFO.isAllowedType(type) ? (type as TOscillatorType) : undefined,
frequency: 0.5
});
// Add one to the output signals, making the range [0, 2].
this.offsetNode = new ConstantSourceNode(context, { offset: 1 });
this.offsetNode.start();
// Divide the result by 2, making the range [0, 1].
this.rangeNode = new GainNode(context, { gain: 0.5 });
this.depthNode = new GainNode(context);
// Map the oscillator's output range from [-1, 1] to [0, 1].
this.osc.connect(this.offsetNode.offset as any);
this.offsetNode.connect(this.rangeNode).connect(this.depthNode);
}
model: string,
protected defaults: MuffSettings,
tunings: MuffTuningOptions
) {
super(context, model);
this.tunings = { ...Muff.defaultTunings, ...tunings };
// Boost stage - pre-filtering + boost gain.
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;
});
// 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)
});
this.postHighpass2Stage = new IIRFilterNode(context, {
...onePoleLowpass(postRange[3], context.sampleRate)
});
// Equalization stage.
this.toneNode = new MixedTone(context, this.tunings.toneRange);
// Output stage.
this.levelNode = context.createGain();
super(context, model);
this.tunings = { ...Muff.defaultTunings, ...tunings };
// Boost stage - pre-filtering + boost gain.
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)
});
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)
});
this.postHighpass2Stage = new IIRFilterNode(context, {
...onePoleLowpass(postRange[3], context.sampleRate)
});
// Equalization stage.
this.toneNode = new MixedTone(context, this.tunings.toneRange);
// Output stage.
this.levelNode = context.createGain();
this.processor = [
this.boostNode,
this.preLowpass,
});
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)
});
this.postHighpass2Stage = new IIRFilterNode(context, {
...onePoleLowpass(postRange[3], context.sampleRate)
});
// Equalization stage.
this.toneNode = new MixedTone(context, this.tunings.toneRange);
// Output stage.
this.levelNode = context.createGain();
this.processor = [
this.boostNode,
this.preLowpass,
this.preHighpass,
this.waveSharper1Stage,
this.postLowpass1Stage,
this.postHighpass1Stage,