-
Notifications
You must be signed in to change notification settings - Fork 1
Audio
The AudioComponents integrate the WebAudio-API into FUDGE. WebAudio allows for a wide range of audio application and manipulation including sound generation, effects and spatial location and emission. It is a system using so called Audio-Graphs and is completely separated from the DOM and WebGL. To learn more about the API, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API
Using the Audioclasses of FUDGE, it is possible to connect the Audio-Graphs to FUDGE-Graphs to create auditive experiences matching the visual impressions.
Extends the standard AudioContext for integration with FUDGE-graphs and creates a default object at startup to be addressed as AudioManager.default
. It contains a master gain, and accepts a node as the root of the graph to listen to and a ComponentAudioListener to describe the reception of the audio.
Extends the audio buffer with methods to load audio ressources (mp3).
Synchronizes audio with the FUGDE-Node it's attached to in respect to its world position and allows for specific adjustment of the volume. Effects may be added by inserting the standard Audio-Nodes of the WebAudio-API.
Serves to set the spatial location and orientation of the reception of the audio relative to the world transformation of the FUDGE-node it is attached to.
Consider a scene with the players avatar having a conversation with an NPC in a threedimensional environment. A simplified diagram explaining the connection between the FUDGE-graph with its nodes and components and the AudioContext controlled by it may look like this.
The players avatar has a ComponentAudioListener attached, since the player should hear what the avatar hears. It also contains a ComponentAudio to play the question to ask the NPC. This component controls a source-node in the AudioContext to play the audiodata, and a panner-node to locate the audio in the world. Since its in the same spot as the listener, its gain may be reduced a bit using the gain node. The NPC uses the audio-resource called "answer" in the same manner, here probably with full gain, since it's located further away from the avatar and the NPC needs to yell. The audiocontext mixes both audiosignals, applies a master gain and sends the result to the speakers.