Releases: benji6/virtual-audio-graph
Releases · benji6/virtual-audio-graph
v1.1.1
v1.1.0
v1.0.4
v1.0.3
v1.0.2
v1.0.1
v1.0.0 (No changes from 0.20.0)
v0.20.0
0.20.0 (2018-03-28)
Features
- api: Use functions for creating virtual audio nodes (7ee89ed)
BREAKING: If using commonJS createVirtualAudioGraph must be imported as:
const createVirtualAudioGraph = require('virtual-audio-graph').default
BREAKING: Nodes in the audioGraph are now defined using functions instead of arrays
Inspired by https://github.com/ohanhi/hyperscript-helpers
Instead of:
import createVirtualAudioGraph from 'virtual-audio-graph'
const virtualAudioGraph = createVirtualAudioGraph()
const {currentTime} = virtualAudioGraph
const graph = {
0: ['gain', 'output', {gain: 0.2}],
1: ['oscillator', 0, {
type: 'square',
frequency: 440,
startTime: currentTime + 1,
stopTime: currentTime + 2
}],
2: ['oscillator', 0, {
type: 'sawtooth',
frequency: 660,
detune: 4,
startTime: currentTime + 1.5,
stopTime: currentTime + 2.5
}],
}
virtualAudioGraph.update(graph)
We now have:
import createVirtualAudioGraph, {gain, oscillator} from 'virtual-audio-graph'
const virtualAudioGraph = createVirtualAudioGraph()
const {currentTime} = virtualAudioGraph
const graph = {
0: gain('output', {gain: 0.2}),
1: oscillator(0, {
type: 'square',
frequency: 440,
startTime: currentTime + 1,
stopTime: currentTime + 2
}),
2: oscillator(0, {
type: 'sawtooth',
frequency: 660,
detune: 4,
startTime: currentTime + 1.5,
stopTime: currentTime + 2.5
}),
}
virtualAudioGraph.update(graph)
BREAKING: Custom nodes must now be created with the createNode
function:
import {createNode, delay, gain, oscillator, stereoPanner} from 'virtual-audio-graph'
const pingPongDelay = createNode(({
decay = 1 / 3,
delayTime = 1 / 3,
maxDelayTime = 1 / 3,
} = {}) => ({
0: stereoPanner('output', {pan: -1}),
1: stereoPanner('output', {pan: 1}),
2: delay([1, 'five'], {delayTime, maxDelayTime}),
3: gain(2, {gain: decay}),
import {createNode, delay, gain, oscillator, stereoPanner} from 'virtual-audio-graph'
const pingPongDelay = createNode(({
decay = 1 / 3,
delayTime = 1 / 3,
maxDelayTime = 1 / 3,
} = {}) => ({
0: stereoPanner('output', {pan: -1}),
1: stereoPanner('output', {pan: 1}),
2: delay([1, 'five'], {delayTime, maxDelayTime}),
3: gain(2, {gain: decay}),
4: delay([0, 3], {delayTime, maxDelayTime}),
five: gain(4, {gain: decay}, 'input') // note this is the destination for nodes which connect to pingPongDelay
}))
virtualAudioGraph.update({
0: pingPongDelay(
'output',
{decay: 1 / 4, delayTime: 1 / 3, maxDelayTime: 1},
),
1: gain([0, 'output'], {gain: 1 / 4}),
2: oscillator(1, {frequency: 440, type: 'square'}),
})