| @@ -18,16 +18,17 @@ function setVolume(vol) { | |||||
| function playSfx(name) { | function playSfx(name) { | ||||
| if (waiting[name]) { | |||||
| waiting[name].push({ | |||||
| type: "sfx", | |||||
| name: name | |||||
| }); | |||||
| console.error(name + " isn't ready yet"); | |||||
| return; | |||||
| } | |||||
| if (audioDict[name] == undefined) { | if (audioDict[name] == undefined) { | ||||
| if (waiting[name]) { | |||||
| waiting[name].push({ | |||||
| type: "sfx", | |||||
| name: name | |||||
| }); | |||||
| console.warn(name + " isn't ready yet"); | |||||
| return; | |||||
| } | |||||
| console.error(name + " is not loaded yet, dingus"); | console.error(name + " is not loaded yet, dingus"); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -46,16 +47,16 @@ function playSfx(name) { | |||||
| function playLoop(name) { | function playLoop(name) { | ||||
| if (waiting[name]) { | |||||
| waiting[name].push({ | |||||
| type: "loop", | |||||
| name: name | |||||
| }); | |||||
| console.error(name + " isn't ready yet"); | |||||
| return; | |||||
| } | |||||
| if (audioDict[name] == undefined) { | if (audioDict[name] == undefined) { | ||||
| if (waiting[name]) { | |||||
| waiting[name].push({ | |||||
| type: "loop", | |||||
| name: name | |||||
| }); | |||||
| console.warn(name + " isn't ready yet"); | |||||
| return; | |||||
| } | |||||
| console.error(name + " is not loaded yet, dingus"); | console.error(name + " is not loaded yet, dingus"); | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -68,7 +69,7 @@ function playLoop(name) { | |||||
| let src = audioContext.createBufferSource(); | let src = audioContext.createBufferSource(); | ||||
| src.buffer = audioDict[name]; | src.buffer = audioDict[name]; | ||||
| src.connect(audioContext.destination); | |||||
| src.connect(gainControl); | |||||
| looping[name] = src; | looping[name] = src; | ||||
| @@ -158,7 +159,10 @@ function parseAudioData(name, data) { | |||||
| audioContext.decodeAudioData(data, function(buffer) { | audioContext.decodeAudioData(data, function(buffer) { | ||||
| audioDict[name] = buffer; | audioDict[name] = buffer; | ||||
| console.log(waiting); | |||||
| waiting[name].forEach(queued => { | waiting[name].forEach(queued => { | ||||
| console.log(queued); | |||||
| if (queued.type == "sfx") { | if (queued.type == "sfx") { | ||||
| playSfx(name); | playSfx(name); | ||||
| } | } | ||||
| @@ -167,8 +171,9 @@ function parseAudioData(name, data) { | |||||
| playLoop(name); | playLoop(name); | ||||
| } | } | ||||
| delete waiting[name]; | |||||
| }) | |||||
| }); | |||||
| delete waiting[name]; | |||||
| }, function(e){ | }, function(e){ | ||||
| console.log("Error with decoding audio data" + e.err); | console.log("Error with decoding audio data" + e.err); | ||||
| delete waiting[name]; | delete waiting[name]; | ||||