How to use the virtual-audio-graph.default function in virtual-audio-graph

To help you get started, we’ve selected a few virtual-audio-graph 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 miselaytes-anton / web-audio-experiments / packages / guitar-app / src / index.js View on Github external
'use strict';

const {createStore} = require('redux');
const {isEmpty} = require('lodash')
const {default: createVirtualAudioGraph} = require('virtual-audio-graph');
const {makeDistortionCurve, getGuitarSoundBuffer, stateToGraph} = require('./utils');
const reducer = require('./reducer')
const ui = require('./ui')

const audioContext = new AudioContext();

const virtualAudioGraph = createVirtualAudioGraph({
  audioContext,
  output: audioContext.destination,
});

// update using virtualAudioGraph
const updateAudioNodes = state => virtualAudioGraph.update(stateToGraph(state));

// update using plain Web Audio API
const nodes = {};
const updateAudioNodes2 = state => {
  if (isEmpty(nodes)) {
    // creating nodes
    nodes.volume = audioContext.createGain();
    nodes.distortion = audioContext.createWaveShaper();
    nodes.distortion.oversample = state.distortion[2].oversample;
    nodes.guitar = audioContext.createBufferSource();