Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ambisonic Audio Using the WebAudio API - Mario ...

Demuxed
October 05, 2017

Ambisonic Audio Using the WebAudio API - Mario Guggenberger

360-degree videos are becoming mainstream media and promise an immersive experience. Adjusting the video viewport according to the user or device movements is just half the battle. Not only video but also audio is an important factor for an immersive experience. In this talk I will show how ambisonic audio can be handled in JavaScript using the WebAudio API, to enrich 360 video experiences with true "surround" sound.

Presented at Demuxed 2017 by Mario Guggenberger

Demuxed

October 05, 2017
Tweet

More Decks by Demuxed

Other Decks in Technology

Transcript

  1. SPACIAL AUDIO RECORDING W X Y Z Pictures: University of

    Southern Queensland / Dynamics II, Shure
  2. HRTF DB HRTF DB HRTF: APPLICATION SOUND HRTF DB FILTER

    FILTER Az, El R L binaural playback
  3. 360° IMMERSIVE VR AUDIO ROTATION HRTF HRTF HRTF … Ambisonics

    + HRTF + Headphones = Binaural 3D Audio
  4. WEB AUDIO API: EXAMPLE MediaElementAudioSourceNode AudioDestinationNode Audio Hardware HTMLMediaElement <video

    id="myMediaElement" src="videoWithAudio.mp4"></video>
 <script>
 const mediaElement = document.getElementById('myMediaElement');
 const audioContext = new AudioContext();
 const audioSource = audioContext.createMediaElementSource(mediaElement); // Connect audio graph
 audioSource.connect(audioContext.destination);
 </script>
  5. WEB AUDIO API: AUDIO NODES OscillatorNode AudioBufferSourceNode AudioDestinationNode ConvolverNode MediaElementAudioSourceNode

    DelayNode GainNode StereoPannerNode DynamicsCompressorNode MediaStreamAudioSourceNode BiquadFilterNode WaveShaperNode IIRFilterNode MediaStreamAudioDestinationNode AnalyserNode ChannelSplitterNode ChannelMergerNode PannerNode AudioWorkerNode
  6. WEB AUDIO API: EXAMPLE Gain <video id="myMediaElement" src="videoWithAudio.mp4"></video>
 <script>
 const

    mediaElement = document.getElementById('myMediaElement');
 const audioContext = new AudioContext();
 const audioSource = audioContext.createMediaElementSource(mediaElement);
 const gainNode = audioContext.createGain();
 // Connect audio graph
 audioSource.connect(gainNode);
 gainNode.connect(audioContext.destination);
 // Set parameters
 gainNode.gain.value = 0.5;
 </script> MediaElementAudioSourceNode AudioDestinationNode Audio Hardware HTMLMediaElement GainNode
  7. WEB AUDIO API: EXAMPLE MediaElementAudioSourceNode AudioDestinationNode Audio Hardware HTMLMediaElement GainNode

    OscillatorNode <video id="myMediaElement" src="videoWithAudio.mp4"></video>
 <script>
 const mediaElement = document.getElementById('myMediaElement');
 const audioContext = new AudioContext();
 const audioSource = audioContext.createMediaElementSource(mediaElement);
 const gainNode = audioContext.createGain();
 const oscillatorNode = audioContext.createOscillator();
 // Connect audio graph
 audioSource.connect(gainNode);
 oscillatorNode.connect(gainNode.gain);
 gainNode.connect(audioContext.destination);
 // Set parameters
 oscillatorNode.type = 'sine’;
 oscillatorNode.frequency.value = 0.1; // Hz
 oscillatorNode.start();
 </script> Type Frequency
  8. PRACTIAL CONSIDERATIONS • Limited number of AudioContext instances • Share

    instances between multiple video players • Use provided node types as much as possible • They cover many use-cases
  9. PRACTIAL CONSIDERATIONS • Channel ordering: Furse-Malham, SID, ACN • Channel

    normalization: maxN, N3D, SN3D • Browser format & channel support • Safari: 6ch AAC • Chrome, Firefox: 6ch AAC, 8ch WAV/OGG/OGG+MP4 • Channel order • E.g. 4ch AAC: • Chrome, Firefox: 0, 1, 2, 3 • Safari: 2, 0, 1, 3 • Test page: https://demo.bitmovin.com/public/mgu/ channeltest/
  10. VIDEO PLAYER REQUIREMENTS • VR video support • Access to

    viewing direction • Access to media element • API direct access, API container access, DOM query • Must not use MediaElementAudioSourceNod e • or provide API into audio path • Ambisonic track detection Player VR support video.js Yes (plugin) JWPlayer Yes (direction?) hls.js No THEOplayer Yes Bitmovin Yes Shaka No
  11. AMBISONICS W/ BITMOVIN PLAYER Load Decoder Select track VR? ON_READY

    ON_AUDIOTRACK_CHANGED ON_VR_VIEWING_DIRECTION_CHANGE Enable Decoder new Ambisonics(player, config?) Disable Decoder Update rotation Ambisonic
 Track? Ambisonic? Decoder
 loaded?
  12. AMBISONICS W/ BITMOVIN PLAYER <AdaptationSet segmentAlignment="true" lang="eng" id="4" bitmovin:label="Ambisonic"> <Role

    schemeIdUri="https://bitmovin.com/082017/vr" value="ambisonic-fo"/> <SegmentTemplate ... /> <Representation ... /> </AdaptationSet> #EXT-X-MEDIA:TYPE=AUDIO,GROUP- ID="ambisonic",NAME="Ambisonic",LANGUAGE="en",
 AUTOSELECT=YES,DEFAULT=YES,CHANNELS="4", URI="audio/ambisonic/stream.m3u8",
 CHARACTERISTICS="com.bitmovin.vr.ambisonic-fo" DASH MANIFEST HLS MASTER PLAYLIST
  13. AMBISONICS W/ BITMOVIN PLAYER • Open Source • Uses Omnitone

    • 260 LOC • 23 kb • Demo (link in README) (headphones!) https://github.com/bitmovin/
 bitmovin-player-vr-ambisonics