Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}