This Web SDK is currently in BETA and is subject to change. Some features may not function correctly, or may be removed in future versions of the software.
Once setupHRTF is done, an HRTFOutput node can be created. This represents the local listener. Connect the
HRTFOutput node through a Limiter to an audio context destination. The
Limiter prevents clipping by converting
the high dynamic range mixed audio into 16-bit audio, suitable for output.
HRTFInput nodes can then be created, as needed for each remote source provided by the transport. Each
should be connected to the
HRTFOutput node. The position (relative to the listener) of an
HRTFInput can be set by
Local audio sources can either be spatialized or non-spatialized. Spatialized sources should be connected via
HRTFInputs to the
HRTFOutput node. Non-spatialized sources should be connected to the
Limiter node so that they
are mixed with the spatialized sources.
Spatialized sources are mono, or if stereo then they are down-mixed by WebAudio to mono. Non-spatialized sources can be either mono or stereo.
Use shutdownHRTF to clean up.
The 2D position and orientation of local audio-sources can be included with transmitted audio data, and audio data from remote sources can contain their position and orientationss. This works on browsers that support either WebRTC Insertable Streams (e.g., Chrome, Edge) or WebRTC Encoded Transform (e.g., Safari).
The HiFiAudioNodes library modifies
RTCPeerConnections so that they are created
encodedInsertableStreams set to
true so that the appropriate insertable streams or encoded transform mechanism can
be used. Import this library before importing any other library that uses
Call isInlineMetadataSupported to check if the browser supports metadata.
Call setupHRTF with a non-null
remotePositionUpdateCallback parameter if you want to use metadata and it is
supported, then call enableInlineMetadata to enable metadata.
To connect the metadata encoders and decoders call setupSenderMetadata on any
WebRTC RTCRtpSenders created, and call
setupReceiverMetadata on any
To transmit the position of the local listener, call setPosition on the HRTFOutput node. When the
position of a remote source changes, the
remotePositionUpdateCallback function provided to setupHRTF is called.
To include the High Fidelity Web Audio Nodes library in your project, use npm:
npm install hifi-audio-nodes@latest --registry https://npm.highfidelity.com/