Resonance Audio
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 calledinitAudio
, like this:
function initAudio(){
}
function update(){ //before this function
- Next, we need to initialize an
AudioContext
, which represents the device's stereo sound. Inside theinitAudio
function, enter the following:
audioContext = new AudioContext();
- Then, we set up the audio scene in
Resonance
and output the binaural audio to the device's stereo output by adding...