Skip to content

Commit

Permalink
Fixed audiocontext duplication bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
chr15m committed Nov 13, 2018
1 parent 1eea3f9 commit 3efd914
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sfxr.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,19 @@ var _sfxr_getNormalized = function(buffer, bitsPerChannel) {
return normalized;
}

var _actx = null;
var _sfxr_getAudioFn = function(wave) {
return function() {
// check for procedural audio
var actx = null;
if ('AudioContext' in window) {
actx = new AudioContext();
} else if ('webkitAudioContext' in window) {
actx = new webkitAudioContext();
if (!_actx) {
if ('AudioContext' in window) {
_actx = new AudioContext();
} else if ('webkitAudioContext' in window) {
_actx = new webkitAudioContext();
}
}
actx = _actx;

if (actx) {
var buff = actx.createBuffer(1, wave.buffer.length, wave.header.sampleRate);
Expand Down

0 comments on commit 3efd914

Please sign in to comment.