Add optional custom input node param

This commit is contained in:
Karishma Chadha 2022-03-09 16:10:48 -05:00
parent 89c345950e
commit b551d26565

View file

@ -41,7 +41,7 @@ const decodeAudioData = function (audioContext, buffer) {
* sprites. * sprites.
*/ */
class AudioEngine { class AudioEngine {
constructor (audioContext = new AudioContext()) { constructor (audioContext = new AudioContext(), optInputNode = null) {
/** /**
* AudioContext to play and manipulate sounds with a graph of source * AudioContext to play and manipulate sounds with a graph of source
* and effect nodes. * and effect nodes.
@ -55,7 +55,7 @@ class AudioEngine {
* will change the volume for all sounds. * will change the volume for all sounds.
* @type {GainNode} * @type {GainNode}
*/ */
this.inputNode = this.audioContext.createGain(); this.inputNode = optInputNode || this.audioContext.createGain();
this.inputNode.connect(this.audioContext.destination); this.inputNode.connect(this.audioContext.destination);
/** /**