Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion js/other/XAudioServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,29 @@ XAudioServer.prototype.initializeWebAudio = function () {
XAudioJSWebAudioAudioNode = XAudioJSWebAudioContextHandle.createJavaScriptNode(XAudioJSSamplesPerCallback, 0, XAudioJSChannelsAllocated); //Create the js event node.
}
XAudioJSWebAudioAudioNode.onaudioprocess = XAudioJSWebAudioEvent; //Connect the audio processing event to a handling function so we can manipulate output
XAudioJSWebAudioAudioNode.connect(XAudioJSWebAudioContextHandle.destination); //Send and chain the output of the audio manipulation to the system audio output.
var gainNode = XAudioJSWebAudioContextHandle.createGain();
XAudioJSWebAudioAudioNode.connect(gainNode); //Connect the audio processing event to a handling function so we can manipulate output
gainNode.connect(XAudioJSWebAudioContextHandle.destination);
gainNode.gain.value = 0.001;
gainNode.gain.exponentialRampToValueAtTime(
1,
XAudioJSWebAudioContextHandle.currentTime + 0.5
);

document.addEventListener("visibilitychange", function(event) {
if (document.hidden) {
gainNode.gain.exponentialRampToValueAtTime(
0.0001,
XAudioJSWebAudioContextHandle.currentTime + 0.5
);
} else {
gainNode.gain.exponentialRampToValueAtTime(
1,
XAudioJSWebAudioContextHandle.currentTime + 0.5
);
}
});

this.resetCallbackAPIAudioBuffer(XAudioJSWebAudioContextHandle.sampleRate);
this.audioType = 1;
/*
Expand Down