How to use the standardized-audio-context.GainNode function in standardized-audio-context

To help you get started, we’ve selected a few standardized-audio-context examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vitaliy-bobrov / js-rocks / src / app / audio / effects / distortion.ts View on Github external
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();
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / chorus.ts View on Github external
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();
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / lfo.ts View on Github external
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);
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / tremolo.ts View on Github external
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();
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / lfo.ts View on Github external
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);
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / reverb.ts View on Github external
constructor(
    context: AudioContext,
    model: string,
    buffer$: Observable,
    convolverMakeUp: number,
    protected defaults: ReverbSettings
  ) {
    super(context, model);

    this.splitter = new ChannelSplitterNode(context);
    this.timeNode = new DelayNode(context);
    this.toneNode = new StandardTone(context);
    this.convolver = new ConvolverNode(context);
    this.wet = new GainNode(context);
    this.dry = new GainNode(context);
    this.merger = new ChannelMergerNode(context);
    this.makeUpGain = new GainNode(context);

    this.processor = [
      this.splitter,
      this.timeNode,
      ...this.toneNode.nodes,
      this.convolver,
      this.wet,
      this.merger,
      this.makeUpGain
    ];

    connectNodes(this.processor);
    this.splitter.connect(this.dry).connect(this.merger, 0, 1);
github vitaliy-bobrov / js-rocks / src / app / audio / effects / cabinet.ts View on Github external
constructor(
    context: AudioContext,
    model: string,
    buffer$: Observable,
    gain: number,
    private maxGain: number
  ) {
    super(context, model);

    this.convolver = new ConvolverNode(context);
    this.makeUpGain = new GainNode(context, { gain });
    this.defaults.gain = gain;

    this.bassNode = new BiquadFilterNode(context, {
      type: 'lowshelf',
      frequency: 320,
      gain: 0
    });

    this.midNode = new BiquadFilterNode(context, {
      type: 'peaking',
      Q: Math.SQRT1_2,
      frequency: 1000,
      gain: 0
    });

    this.trebleNode = new BiquadFilterNode(context, {
github vitaliy-bobrov / js-rocks / src / app / audio / effects / compressor.ts View on Github external
constructor(
    context: AudioContext,
    model: string,
    protected defaults: CompressorSettings
  ) {
    super(context, model);

    this.levelNode = new GainNode(context);
    this.compressor = new DynamicsCompressorNode(context, {
      knee: 30,
      release: 0.25
    });

    this.processor = [this.compressor, this.levelNode];

    connectNodes(this.processor);
    this.applyDefaults();
  }
github vitaliy-bobrov / js-rocks / src / app / audio / effects / reverb.ts View on Github external
context: AudioContext,
    model: string,
    buffer$: Observable,
    convolverMakeUp: number,
    protected defaults: ReverbSettings
  ) {
    super(context, model);

    this.splitter = new ChannelSplitterNode(context);
    this.timeNode = new DelayNode(context);
    this.toneNode = new StandardTone(context);
    this.convolver = new ConvolverNode(context);
    this.wet = new GainNode(context);
    this.dry = new GainNode(context);
    this.merger = new ChannelMergerNode(context);
    this.makeUpGain = new GainNode(context);

    this.processor = [
      this.splitter,
      this.timeNode,
      ...this.toneNode.nodes,
      this.convolver,
      this.wet,
      this.merger,
      this.makeUpGain
    ];

    connectNodes(this.processor);
    this.splitter.connect(this.dry).connect(this.merger, 0, 1);

    this.applyDefaults();
    this.updateConvolver(buffer$, convolverMakeUp, this.type);
github vitaliy-bobrov / js-rocks / src / app / audio / audio-context-manager.service.ts View on Github external
constructor() {
    this.context = new AudioContext({
      latencyHint: 'interactive'
    });
    this.masterGain = new GainNode(this.context);
    this.masterGain.connect(this.context.destination);
    this.masterSub$.next(1);
  }