custom-audio-node-connect
custom-audio-node-connect
shims the AudioNode.connect
method and lets you choose which audio nodes to actually connect to each other.
This is useful if you want your own custom nodes/effects to be chainable just like any other node.
The code in this module is copied straight from the terrific tuna
by Theodeus. All cred goes there!
Installation
npm i -S custom-audio-node-connect
Usage
import enableCustomConnects from 'custom-audio-node-connect'
import BitCrusher from './my-effects/BitCrusher.js'
const ctx = new AudioContext()
const inputSelector = (node) => node.input || node
enableCustomConnects(ctx, inputSelector)
const osc = ctx.createOscillator()
osc.frequency.value = 440
const crushEffect = new BitCrusher()
osc.connect(crushEffect)
crushEffect.connect(ctx.destination)
API
### enableCustomConnects(audioContext, inputSelector)
audioContext
An AudioContext
instance.
inputSelector
(node: any) => AudioNode
A function that takes any object passed to AudioNode.connect()
and return and AudioNode
that the connecting node should connect to.
See also
audio-param-shim
- An AudioParam shim that lets you act on value changes in any way you wantTheodeus/tuna
- An audio effects library for the Web Audio API.