Roblox UtilitiesDevlHub Roblox Documentation

Class

AudioListener

Inherits
Instance › Object
Memory category
Internal

Records an audio stream from its surrounding AudioEmitters in the 3D world.

AudioListener records an audio stream from its surrounding AudioEmitters in the 3D world. It provides a single Output pin which can be connected to other pins via Wires. If the parent is an Attachment, Camera, or PVInstance, the parent's world CFrame will be used for listening. If the parent is not one of these classes, the AudioListener effectively hears nothing.

Properties 7#

AcousticSimulationEnabledbooleanDetermines whether acoustic simulation should be used for this AudioListener.ReadSafe
AngleAttenuationBinaryStringRepresents how the perceived volume of the emitted sound changes based on the angle between a AudioEmitter and the LookVector associated with the AudioListener.Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe
AudioInteractionGroupstringControls which AudioEmitters are audible to this AudioListener.ReadSafe
DistanceAttenuationBinaryStringRepresents how the perceived volume of emitted sounds change as the distance between AudioEmitters and the AudioListener increases.Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe
PositionInstanceInstanceThe Instance whose position and orientation is used as the listener's position if PositionType is set to ListenerPositionType.Instance.ReadSafe
PositionTypeListenerPositionTypeDetermines how the AudioListener determines its 3D location.ReadSafe
SimulationFidelityAudioSimulationFidelityControls how detailed the audio simulation should be for this AudioListener.ReadSafe

AcousticSimulationEnabled: boolean#

ReadSafe

Determines whether sound being heard by this AudioListener shoud automatically implement features of acoustic simulation, such as occlusion (being muffled through walls), diffraction (bending around corners), and reverberation (echoing off of walls), when being sourced from an AudioEmitter. Note that the AudioEmitter also needs its AcousticSimulationEnabled property set to true for the effects to occur.

AngleAttenuation: BinaryString#

Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe

Represents a volume-over-angle curve that affects how loudly a AudioListener will hear the AudioEmitter, based on the angle between them and the LookVector associated with the AudioListener.

This property is internal and can't be accessed by scripts; it exists to support replication. See SetAngleAttenuation() for usage details.

AudioInteractionGroup: string#

ReadSafe

Controls which AudioEmitters are audible to this AudioListener. Emitters that share an interaction group can be heard by this Listener.

DistanceAttenuation: BinaryString#

Read: RobloxEngineSecurityWrite: RobloxEngineSecurityReadSafe

Represents a volume-over-distance curve that affects how loudly the AudioListener hears any AudioEmitters, based on the distance between them.

This property is internal and can't be accessed by scripts; it exists to support replication. See SetDistanceAttenuation() for usage details.

PositionInstance: Instance#

ReadSafe

This property is only functional when PositionType is set to ListenerPositionType.Instance. In that scenario, this property determines which Instance will be used to determine the position of the AudioListener when hearing spatial audio from AudioEmitters.

If set to an instance without a position or nil, the AudioListener will not hear anything.

PositionType: ListenerPositionType#

ReadSafe

The method by which the AudioListener determines its 3D location (the point from which any nearby AudioEmitters can be heard). Defaults to ListenerPositionType.Parent.

SimulationFidelity: AudioSimulationFidelity#

DeprecatedReadSafe

Controls how detailed the audio simulation should be for this AudioListener, similar to MeshPart.CollisionFidelity or MeshPart.RenderFidelity.

AudioListeners and AudioEmitters which disagree on the necessary level of detail will use the less-detailed option.

Methods 9#

GetAngleAttenuationGets the angle attenuation curve that the AudioListener is using, or an empty table if it's using the default curve.CustomLuaState
GetAudibilityForCalculates how audible an AudioEmitter is for this listener
GetConnectedWiresReturns an array of Wires that are connected to the specified pin.
GetDistanceAttenuationGets the distance attenuation curve that the AudioListener is using, or an empty table if it's using the default curve.CustomLuaState
GetInputPinsGets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.
GetInteractingEmittersLists all AudioEmitters that this listener is capable of hearing.
GetOutputPinsGets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.
SetAngleAttenuationSets the angle attenuation curve that the AudioListener should use, or uses a constant curve of volume 1 if none is provided.CustomLuaState
SetDistanceAttenuationSets the distance attenuation curve that the AudioListener should use, or uses an inverse rolloff curve if none is provided.CustomLuaState

GetAngleAttenuation(): Dictionary#

CustomLuaState

Returns a table mapping angle to volume. Keys are numbers between 0 and 180 (inclusive), while values are numbers between 0 and 1 (inclusive) describing how volume attenuates depending on direction. This method returns an empty table if the default angle attenuation curve is being used.

Returns
  • Dictionary — Table mapping angle to volume, as described above.

GetAudibilityFor(emitter: AudioEmitter): float#

Calculates how audible an AudioEmitter is for this listener. The resulting volume, ranging from 0 to 1, accounts for distance and angle attenuation on both the emitter and listener. Use this to drive game logic that depends on perceived loudness, such as proximity UI indicators or mechanics that scale with how clearly a sound source is heard.

NameTypeDefaultDescription
emitterAudioEmitterThe AudioEmitter whose audibility should be calculated relative to this listener.
Returns
  • float — A number between 0 and 1 representing the combined volume after distance and angle attenuation from both the emitter and listener.

GetConnectedWires(pin: string): List<Wire>#

Returns an array of Wires that are connected to the specified pin. AudioListener has one "Output" pin.

NameTypeDefaultDescription
pinstringAn input or output pin on this instance
Returns
  • List<Wire> — An array of Wires

GetDistanceAttenuation(): Dictionary#

CustomLuaState

Returns a table mapping distance to volume. Keys are numbers greater than or equal to 0, while values are numbers between 0 and 1 (inclusive) describing how volume attenuates over distance. This method returns an empty table if the default distance attenuation curve is being used.

Returns
  • Dictionary — A table mapping distance keys to volume values, or an empty table if the default curve is being used.

GetInputPins(): Array#

Gets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.

For AudioListener, there are none.

Returns
  • Array — An array of strings representing valid pin names.

GetInteractingEmitters(): List<AudioEmitter>#

Returns an array of AudioEmitters that share an AudioInteractionGroup with the listener.

Returns

GetOutputPins(): Array#

Gets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.

For AudioListener, this is Output only.

Returns
  • Array — An array of strings representing valid pin names.

SetAngleAttenuation(curve: Dictionary): ()#

CustomLuaState

Sets a volume-over-angle curve that affects how loudly a AudioListener will hear the AudioEmitter, based on the angle between them and the LookVector associated with the AudioListener.

The curve is represented by a table mapping angle keys to volume values. Keys are expected to be unique numbers between 0 and 180 (inclusive), while values are expected to be numbers between 0 and 1 (inclusive). Tables containing up to 400 key-value pairs are supported.

The volume of a AudioEmitter from the perspective of the AudioListener at an angle a is determined by linearly interpolating between the volume levels for the points on the curve whose angle values are directly above and below a. If there is either no point below a or no point above a, the volume level of the other point is chosen. Essentially, the curve is a sequence of points connected by straight lines, and beyond its left and right endpoints the curve extends outward at their respective volume levels.

This volume will be multiplied with the volumes from all other attenuation curves (including the ones on the sending AudioEmitter) to obtain the final audibility.

If the table is empty or nil, the AudioListener defaults to using an angle attenuation curve with the constant volume value of 1.

NameTypeDefaultDescription
curveDictionaryA table mapping angle keys (0 to 180) to volume values (0 to 1), or an empty/nil table to use the default constant volume of 1.
Returns
  • ()

SetDistanceAttenuation(curve: Dictionary): ()#

CustomLuaState

Sets a volume-over-distance curve that affects how loudly the AudioListener will hear any AudioEmitters, based on the distance between them. This is useful when you want a particular listener to have an extended or shortened hearing range — for example, a character with enhanced hearing — without modifying the emitting AudioEmitter or separating emitters and listeners into different interaction groups.

The curve is represented by a table mapping distance keys to volume values. Keys are expected to be unique numbers greater than or equal to 0, while values are expected to be numbers between 0 and 1 (inclusive). Tables containing up to 400 key-value pairs are supported.

The volume of a AudioEmitter from the perspective of the AudioListener at a distance d is determined by linearly interpolating between the volume levels for the points on the curve whose distance values are directly above and below d. If there is either no point below d or no point above d, the volume level of the other point is chosen. Essentially, the curve is a sequence of points connected by straight lines, and beyond its left and right endpoints the curve extends outward infinitely at their respective volume levels.

This volume will be multiplied with the volumes from all other attenuation curves (including the ones on the sending AudioEmitter) to obtain the final audibility.

If the table is empty or nil, the AudioListener defaults to applying a constant volume of 1 everywhere.

NameTypeDefaultDescription
curveDictionaryA table mapping distance keys (greater than or equal to 0) to volume values (0 to 1), or an empty/nil table to use the default constant volume of 1 everywhere.
Returns
  • ()

Events 1#

WiringChangedFires when another instance is connected to or disconnected from the AudioListener via a Wire.

WiringChanged(connected: boolean, pin: string, wire: Wire, instance: Instance)#

Event that fires after a Wire becomes connected or disconnected, and that Wire is now or was previously connected to a pin on the AudioListener and to some other wirable instance.

NameTypeDefaultDescription
connectedbooleanWhether the instance got connected or disconnected.
pinstringThe pin on the AudioListener that the Wire targets.
wireWireThe Wire between the AudioListener and the other instance.
instanceInstanceThe other instance that is or was connected through the Wire.

Inherited members#

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed