Class: AudioEmitter

AudioEmitter

AudioEmitter is a Component that allows playing back audio from the Entity's position. If any component wishes to trigger playback from the Entity's origin, that Entity should have the AudioEmitter component assigned which in turn should be retrieved from the Component triggering the playback. Another way of triggering/stopping playback is broadcasting AudioEmitter.PLAY_MESSAGE or AudioEmitter.STOP_MESSAGE with the AudioEmitter's name as parameter. Most of the panning properties are wrappers for PannerNode.


new AudioEmitter(clip)

Parameters:
Name Type Description
clip

The audio clip to be played by this AudioEmitter. Multiple AudioClips can be added to an Entity.

Properties:
Name Type Description
name

Allows tagging AudioEmitters with a name. For instance: collision sounds could have the name "collision"

autoplay

If true, playback starts when the component is added. Usually used with looping AudioClips.

coneInnerAngle

The angle in radians (!!!) of a cone inside of which there will be no volume reduction.

coneOuterAngle

The angle in radians (!!!) of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain attribute.

coneOuterGain

The amount of volume reduction outside the cone defined by the coneOuterAngle attribute. Its default value is 0, meaning that no sound can be heard.

distanceModel

One of AudioDistanceModel, determining which algorithm to use to reduce the volume of the audio source as it moves away from the listener. Defaults to "linear".

maxDistance

Represents the maximum distance between the audio source and the listener, after which the volume is not reduced any further.

panningModel

One of AudioPanningModel, determining which spatialisation algorithm to use to position the audio in 3D space. Defaults to "hrtf".

refDistance

Representing the reference distance for reducing volume as the audio source moves further from the listener. {@see AudioDistanceModel}

rolloffFactor

Describes how quickly the volume is reduced as the source moves away from the listener. This value is used by all distance models. {@see AudioDistanceModel}

Author:
  • derschmale <http://www.derschmale.com>

Methods


clone()

Returns:
Type
AudioEmitter

onAdded()


onRemoved()


play( [gain])

Starts playback of the audio clip.

Parameters:
Name Type Argument Description
gain Number <optional>

The gain of the volume. If provided, this parameter will override the currently assigned gain of the component.


stop()

Stops playback of the audio clip.