Standard Virtual Audio Node Factories
July 12, 2024 ยท View on GitHub
Here is a list of the standard virtual audio node factories exported by virtual-audio-graph and the params you can provide them with (the virtual-audio-graph guide is here).
analyser
analyser(output, {
fftSize,
minDecibels,
maxDecibels,
smoothingTimeConstant,
}]
bufferSource
const {
audioContext,
audioContext: { sampleRate },
} = virtualAudioGraph;
const buffer = audioContext.createBuffer(2, sampleRate * 2, sampleRate);
bufferSource(output, {
buffer,
loop,
loopEnd,
loopStart,
// The offset parameter, which defaults to 0
// and defines where the playback will start
offsetTime,
onended,
playbackRate,
// time in seconds since virtualAudioGraph.currentTime
// was 0, if not provided then node starts immediately
startTime,
// if not provided then stop is not called on node
// until it is disconnected
stopTime,
});
biquadFilter
biquadFilter(output, { type, frequency, detune, Q });
channelMerger
channelMerger(output, { numberOfInputs });
channelSplitter
NB ChannelSplitter has it's own syntax for the output parameter. Because the channel is split it means each node can have multiple outputs. Each output is indexed and the outputs property should be an array of these indices. Then the inputs property should be an array of indices corresponding to the inputs of the destination node. Check out the spec and the link above for more info.
channelSplitter({ key, outputs, inputs }, { numberOfOutputs });
convolver
convolver(output, { buffer, normalize });
delay
NB maxDelayTime must be set when node is first created but cannot be updated. A new node will have to be inserted if a different maxDelayTime is required.
delay(output, { delayTime, maxDelayTime });
dynamicsCompressor
dynamicsCompressor(output, {
attack,
knee,
ratio,
release,
threshold,
}]
gain
gain(output, { gain });
mediaElementSource
NB params can only be set once
mediaElementSource(output, { mediaElement });
mediaStreamDestination
This node has no output as it is a destination. It also takes no parameters. Use virtualAudioGraph.getAudioNodeById method to access the node's stream property
mediaStreamDestination();
mediaStreamSource
NB params can only be set once
mediaStreamSource(output, { mediaStream });
oscillator
oscillator(output, {
type,
frequency,
detune,
// time in seconds since virtualAudioGraph.currentTime
// was 0, if not provided then node starts immediately
startTime,
// if not provided then stop is not called on node until it is disconnected
stopTime,
});
panner
panner(output, {
coneInnerAngle,
coneOuterAngle,
coneOuterGain,
distanceModel,
// applies an array of arguments with the corresponding AudioNode setter:
orientation,
panningModel,
// applies an array of arguments with the corresponding AudioNode setter:
position,
maxDistance,
refDistance,
rolloffFactor,
});
stereoPanner
stereoPanner(output, { pan });
waveShaper
waveShaper(output, { curve, oversample });