High Fidelity Web AudioNodes

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.

HiFiAudioNodes

HiFiAudioNodes provides several WebAudio compatible nodes and WebRTC compatible interfaces.

WebAudio Nodes

Start by creating an AudioContext with a sampleRate of 48000 and then call setupHRTF to load needed WASM modules.

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 HRTFInput should be connected to the HRTFOutput node. The position (relative to the listener) of an HRTFInput can be set by calling setPosition.

Microphone audio can be connected to a NoiseSuppression or NoiseGate node, and that node's output sent via the transport.

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.

Metadata

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 with 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 RTCPeerConnection.

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 WebRTC RTCRtpReceivers. 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.

Installation

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/

Tutorial

The tutorial demonstrates how you can use this Web SDK with the Agora RTC Web SDK to create a single page application that sends and receives audio among app users.

Index

Classes

Interfaces

Type Aliases

Functions

© 2023 High Fidelity, Inc. | All rights reserved Terms of Service | Privacy Policy