Skip to content

datavized/aframe-ambisonic-component

Repository files navigation

aframe-ambisonic-component

Version License

An Ambisonic Audio component for A-Frame.

Built on Omnitone.

API

Property Description Default Value Values
src The source of the audio. This can be an HTMLMediaElement (<audio /> or <video />), an ID string pointing to an HTMLMediaElement or a resouce string.
sources Load multiple audio files1. Overrides src. Array of URL strings
loop Whether to loop the element source. Overwrites the value set by the input element. true
useMediaElement Whether to use a media element (required for video). Alternatively, load from source as an audio buffer. true
autoplay Whether to autoplay the element source. Overwrites the value set by the input element. true
mode Audio rendering mode ambisonic [oneOf(ambisonic, bypass, off)]
order Order of ambisonic rendering 1 1, 2 or 3
channelMap Ordering of ambisonic component channels ACN [oneOf(ACN), FuMa, SID] or Array of integers

1: Higher-order ambisonic audio requires 9 or 16 channels, but most browsers can only decode 8 channels at a time. So it is necessary to split the audio file into two: each with no more than 8 channels. See Higher Order Ambisonics example.

Installation

Browser

Install and use by directly including the script compiled for the browser:

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script>
  <script src="https://unpkg.com/aframe-ambisonic-component"></script>
</head>

<body>
  <a-scene>
    <a-assets>
      <audio id="audio" src="audiofile.mp4"></audio>
    </a-assets>
    <a-ambisonic src="#audio"></a-entity>
  </a-scene>
</body>

If you already have Omnitone loaded or if you're using another component that loads Omnitone (e.g. aframe-resonance-audio-component), there is a much smaller version of the script that does not include Omnitone.

<script src="https://unpkg.com/aframe-ambisonic-component/build/aframe-ambisonic-component-no-omnitone.min.js"></script>

npm

Install via npm:

npm install aframe-ambisonic-component

Then require and use.

require('aframe');
require('aframe-ambisonic-component');