Google developed Resonance Audio as a tool for developers who need to include 3D spatial audio in their AR and VR applications. We will use this tool to put 3D sound in our demo app. Let's get started by opening up the spawn-at-surface.html file in your favorite text editor and then follow the given steps:
- Locate the beginning of the JavaScript and add the following lines in the variable declarations:
var cube; //after this line
var audioContext;
var resonanceAudioScene;
var audioElement;
var audioElementSource;
var audio;
- Now, scroll down to just before the update function and start a new function called initAudio, like this:
function initAudio(){
}
function update(){ //before this function
- Next, we need to initialize an AudioContext, which represents the device's stereo sound. Inside the initAudio function, enter the following:
audioContext = new AudioContext...