|
|
|
@@ -18,16 +18,17 @@ function setVolume(vol) { |
|
|
|
|
|
|
|
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 (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"); |
|
|
|
return; |
|
|
|
} |
|
|
|
@@ -46,16 +47,16 @@ function playSfx(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 (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"); |
|
|
|
return; |
|
|
|
} |
|
|
|
@@ -68,7 +69,7 @@ function playLoop(name) { |
|
|
|
|
|
|
|
let src = audioContext.createBufferSource(); |
|
|
|
src.buffer = audioDict[name]; |
|
|
|
src.connect(audioContext.destination); |
|
|
|
src.connect(gainControl); |
|
|
|
|
|
|
|
looping[name] = src; |
|
|
|
|
|
|
|
@@ -158,7 +159,10 @@ function parseAudioData(name, data) { |
|
|
|
audioContext.decodeAudioData(data, function(buffer) { |
|
|
|
audioDict[name] = buffer; |
|
|
|
|
|
|
|
console.log(waiting); |
|
|
|
|
|
|
|
waiting[name].forEach(queued => { |
|
|
|
console.log(queued); |
|
|
|
if (queued.type == "sfx") { |
|
|
|
playSfx(name); |
|
|
|
} |
|
|
|
@@ -167,8 +171,9 @@ function parseAudioData(name, data) { |
|
|
|
playLoop(name); |
|
|
|
} |
|
|
|
|
|
|
|
delete waiting[name]; |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
delete waiting[name]; |
|
|
|
}, function(e){ |
|
|
|
console.log("Error with decoding audio data" + e.err); |
|
|
|
delete waiting[name]; |
|
|
|
|