Object3DAudio

PositionalAudio

Create a positional audio object.

This uses the Web Audio API.

Example

webaudio / orientation
webaudio / sandbox
webaudio / timing

// create an AudioListener and add it to the camera var listener = new v3d.AudioListener(); camera.add(listener); // create the PositionalAudio object (passing in the listener) var sound = new v3d.PositionalAudio(listener); // load a sound and set it as the PositionalAudio object's buffer var audioLoader = new v3d.AudioLoader(); audioLoader.load('sounds/song.ogg', function(buffer) { sound.setBuffer(buffer); sound.setRefDistance(20); sound.play(); }); // create an object for the sound to play from var sphere = new v3d.SphereGeometry(20, 32, 16); var material = new v3d.MeshPhongMaterial({ color: 0xff2200 }); var mesh = new v3d.Mesh(sphere, material); scene.add(mesh); // finally add the sound to the mesh mesh.add(sound);

Constructor

PositionalAudio(listener : AudioListener)

listener — (required) AudioListener instance.

Properties

See the Audio class for inherited properties.

.panner : PannerNode

The PositionalAudio's PannerNode.

Methods

See the Audio class for inherited methods.

.getOutput () : PannerNode

Returns the panner.

.getRefDistance () : Float

Returns the value of panner.refDistance.

.setRefDistance (value : Float) : PositionalAudio

Sets the value of panner.refDistance.

.getRolloffFactor () : Float

Returns the value of panner.rolloffFactor.

.setRolloffFactor (value : Float) : PositionalAudio

Sets the value of panner.rolloffFactor.

.getDistanceModel () : String

Returns the value of panner.distanceModel.

.setDistanceModel (value : String) : PositionalAudio

Sets the value of panner.distanceModel.

.getMaxDistance () : Float

Returns the value of panner.maxDistance.

.setMaxDistance (value : Float) : PositionalAudio

Sets the value of panner.maxDistance.

.setDirectionalCone (coneInnerAngle : Float, coneOuterAngle : Float, coneOuterGain : Float) : PositionalAudio

This method can be used in order to transform an omnidirectional sound into a directional sound.

Source

For more info on how to obtain the source code of this module see this page.