commit 1f5d09247cae1deb9c48dd6b7df22d6eb2664810 Author: Fen Dweller Date: Sun Sep 30 22:46:18 2018 -0400 Began work on the audio framework diff --git a/audio.js b/audio.js new file mode 100644 index 0000000..dd68109 --- /dev/null +++ b/audio.js @@ -0,0 +1,49 @@ +let audioDict = {}; + +// play some sound + +function playAudio(name) { + if (audioDict[name] == undefined) { + console.log(name + " is not loaded yet, dingus"); + return; + } + + let src = audioContext.createBufferSource(); + + src.buffer = audioDict[name]; + + src.connect(audioContext.destination); + + src.start(0); +} + +// asynchronously load an audio file + +function loadAudio(name) { + let xhr = new XMLHttpRequest(); + + xhr.open("GET", audioBaseUrl + name, true); + + console.log(audioBaseUrl + name); + xhr.responseType = "arraybuffer"; + console.log("a"); + + xhr.onload = function() { + let data = xhr.response; + console.log("FDSEW"); + + audioContext.decodeAudioData(data, function(buffer) { + console.log("SADFDS"); + audioDict[name] = buffer; + }, function(e){ console.log("Error with decoding audio data" + e.err);}); + + } + + xhr.send(); +} + +function initAudio() { + audioContext = new (window.AudioContext || window.webkitAudioContext)(); + + console.log(audioContext); +} diff --git a/satiate.html b/satiate.html new file mode 100644 index 0000000..fa64264 --- /dev/null +++ b/satiate.html @@ -0,0 +1,20 @@ + + + + + + Satiate + + + + + + + + + + + + +
hewwo?
+ diff --git a/satiate.js b/satiate.js new file mode 100644 index 0000000..b39b4f9 --- /dev/null +++ b/satiate.js @@ -0,0 +1,15 @@ +"use strict" + +let audioBaseUrl = "http://localhost:8000/media/audio/"; + +let audioContext; + +// setup the game + +function init() { + initAudio(); + + +} + +document.addEventListener("load", init);