Reference API Roblox

Engine API

Website

Related

Reference API Roblox

SoundService

A service that determines various aspects of how Sounds play in the game.

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 30

HistoryMember
553AmbientReverb: ReverbType
645DefaultListenerLocation: ListenerLocation
553DistanceFactor: float
553DopplerScale: float
553RespectFilteringEnabled: bool
553RolloffScale: float
553VolumetricAudio: VolumetricAudio
462BeginRecording(): bool
462EndRecording(): Dictionary
645GetAudioInstances(): Array
550GetInputDevice(): Tuple
550GetInputDevices(): Tuple
462GetListener(): Tuple
467GetOutputDevice(): Tuple
467GetOutputDevices(): Tuple
462GetRecordingDevices(): Dictionary
462GetSoundMemoryData(): Dictionary
648OpenAttenuationCurveEditor(selectedCurveObjects: Instances): null
649OpenDirectionalCurveEditor(selectedCurveObjects: Instances): null
573PlayLocalSound(sound: Instance): null
573SetInputDevice(name: string, guid: string): null
573SetListener(listenerType: ListenerType, listener: Tuple): null
573SetOutputDevice(name: string, guid: string): null
462SetRecordingDevice(deviceIndex: int): bool
599AudioInstanceAdded(instance: Instance)
475DeviceListChanged(newDevices: Tuple)
648OpenAttenuationCurveEditorSignal(selectedCurveObjects: Instances)
648OpenAudioEqualizerEditorSignal(selectedEqualizerObjects: Instances)
648OpenDirectionalCurveEditorSignal(selectedCurveObjects: Instances)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 1

HistoryMember
473PlayStockSound(sound: SoundType): void

Description

A service that determines various aspects of how Sounds play in the game. SoundService is also often used to store SoundGroups although this is not mandatory for SoundGroups to work.

What can SoundService do?

SoundService properties such as SoundService.AmbientReverb, SoundService.DistanceFactor, SoundService.DopplerScale and SoundService.RolloffScale can be used to change how all Sounds play in the game.

The SoundService:SetListener() function allows developers to set the position where sounds are heard from.

SoundService:PlayLocalSound() can be used to play a sound locally regardless of where it is parented to.

Developers looking to find out more about how sound works in Roblox should consult the documentation provided for the FMOD sound engine.

History 94

Members 30

AmbientReverb

TypeDefault
ReverbTypeNoReverb

The ambient sound environment preset used by SoundService.

The ReverbType this property simulates a range of different environment's impact on sound. Each different option corresponds with a preset available in the FMOD sound engine. For example, when AmbientReverb is set to Hangar, the sound will reverberate differently to simulate being in a large enclosed space.

Changing the AmbientReverb effects the following properties used by Roblox's sound engine.

  • Reverberation decay time
  • Initial reflection delay time
  • Late reverberation delay time relative to initial reflection
  • Reference high frequency
  • High-frequency to mid-frequency decay time ratio
  • Value that controls the echo density in the late reverberation decay
  • Value that controls the modal density in the late reverberation decay
  • Reference low frequency
  • Relative room effect level at low frequencies
  • Relative room effect level at high frequencies
  • Early reflections level relative to room effect
  • Room effect level at mid frequencies

Those interested in finding more out about ambient reverb presets should see the FMOD documentation on the topic. For most developers however, the ReverbType names are descriptive enough to be able to use this setting without advanced knowledge.

History 7

AudioInstanceAdded

Parameters (1)
instanceInstance

History 1

BeginRecording

Parameters (0)
No parameters.
Returns (1)
bool

History 8

DefaultListenerLocation

TypeDefault
ListenerLocationDefault

History 1

DeviceListChanged

Parameters (1)
newDevicesTuple

History 1

DistanceFactor

TypeDefault
float3.32999992

The number of studs to be considered a meter by SoundService when calculating 3D Sound volume attenuation.

By default, the DistanceFactor is 3.33. This means, for the purposes of volume attenuation, a meter is considered 3.33 studs. The greater the DistanceFactor, the more gradually sound will attenuate.

local SoundService = game:GetService("SoundService")
SoundService.DistanceFactor = 1 -- 1 meter = 1 stud
SoundService.DistanceFactor = 10 -- 1 meter = 10 studs

Developers are advised to only change this property if their game uses a different scale. For example, when using larger custom characters, developers may want to reduce the DistanceFactor. In all other cases, Sound settings such as Sound.RollOffMode should be used instead.

Those looking to find out more about how 3D sound in Roblox works, should consult the FMOD documentation.

History 7

DopplerScale

TypeDefault
float1

This property determines the degree to which a 3D Sound object's pitch varies due to the Doppler effect.

The Doppler effect describes a phenomenon whereby the pitch of a sound changes as the source and observer of the sound move further away, or closer together. The Doppler effect can often be seen in real life, such as when a car with a siren drives past.

Increasing this value exaggerates the impact of the Doppler effect, whereas decreasing it minimizes it. By default, the value of this property is 1.

local SoundService = game:GetService("SoundService")
SoundService.DopplerScale = 1 -- default
SoundService.DopplerScale = 2 -- exaggerated Doppler effect
SoundService.DopplerEffect = 0.5 -- subdued Doppler effect

Note the Doppler effect has no impact on 2D Sounds, (Sounds not parented to a BasePart or Attachment).

Developers wishing to learn more about the different settings Roblox's sound engine uses should consult the FMOD documentation.

History 7

EndRecording

Parameters (0)
No parameters.
Returns (1)
Dictionary
This function yields. It will block the calling thread until completion.

History 11

Tags: [Yields]

GetAudioInstances

Parameters (0)
No parameters.
Returns (1)
Array

History 1

GetInputDevice

Parameters (0)
No parameters.
Returns (1)
Tuple

History 1

GetInputDevices

Parameters (0)
No parameters.
Returns (1)
Tuple

History 1

GetListener

Parameters (0)
No parameters.
Returns (1)
Tuple

This function returns the SoundService current listener type and what is set as listener.

The first result returned is the ListenerType of the listener, the second result is dependent on the ListenerType:

ListenerTypeDescription
ListenerType.CameraDoes not return a listener object as Workspace/CurrentCamera is always used
ListenerType.CFrameReturns the CFrame used in SoundService:SetListener()
ListenerType.ObjectPositionReturns the BasePart used in SoundService:SetListener()
ListenerType.ObjectCFrameReturns the BasePart used in SoundService:SetListener()

The listener can be changed using SoundService:SetListener().

1
2
3
4
local SoundService = game:GetService("SoundService")
SoundService:SetListener(Enum.ListenerType.CFrame, CFrame.new(0, 0, 0))
local listenerType, listener = SoundService:GetListener()
print(listenerType, listener)

What is a listener?

The listener determines the point from which audio in the game is being 'heard' by the player. For 3D Sounds (Sounds parented to a BasePart or Attachment) the listener influences the volume and left/right balance of a playing sound. Listeners have no influence on the playback of 2D sounds as they have no position of emission.

By default, the listener is set to the CurrentCamera. However, a range of different types of listeners can be used.

History 2

GetOutputDevice

Parameters (0)
No parameters.
Returns (1)
Tuple

History 1

GetOutputDevices

Parameters (0)
No parameters.
Returns (1)
Tuple

History 1

GetRecordingDevices

Parameters (0)
No parameters.
Returns (1)
Dictionary
This function yields. It will block the calling thread until completion.

History 2

Tags: [Yields]

GetSoundMemoryData

Parameters (0)
No parameters.
Returns (1)
Dictionary

History 2

OpenAttenuationCurveEditor

Parameters (1)
selectedCurveObjectsInstances
Returns (1)
null

History 2

OpenAttenuationCurveEditorSignal

Parameters (1)
selectedCurveObjectsInstances

History 2

OpenAudioEqualizerEditorSignal

Parameters (1)
selectedEqualizerObjectsInstances

History 2

OpenDirectionalCurveEditor

Parameters (1)
selectedCurveObjectsInstances
Returns (1)
null

History 2

OpenDirectionalCurveEditorSignal

Parameters (1)
selectedCurveObjectsInstances

History 1

PlayLocalSound

Parameters (1)
soundInstance
Returns (1)
null

Plays a Sound locally, meaning the sound will only be heard by the client calling this function, regardless of where it's parented to. This function is most useful for playing a Sound locally in the Studio client, for instance in a Script for a Plugin.

History 3

RespectFilteringEnabled

TypeDefault
boolfalse

The RespectFilteringEnabled property determines whether Sound playback is replicated from the client to the server, and therefore from server. In other words, when a LocalScript calls Sound:Play() and this property is true, the sound will only play on the respective client. If the property is false, other clients will also hear the sound.

History 4

RolloffScale

TypeDefault
float1

Sets how fast 3D Sound volume attenuates, or 'rolls off'.

Note, this property only applies to Sounds whose Sound.RollOffMode property is set to 'Inverse' or 'InverseTapered'. 'Linear' and 'LinearSquare' RollOffMode use a different attenuation model which is not influenced by this property. This property also has no impact on 2D sounds (Sounds not parented to a BasePart or Attachment).

The higher the RolloffScale, the more rapidly a 3D sound's volume will attenuate as the distance between the listener and the sound increases.

By default the roll off scale is set to 1, which simulates the real world.

local SoundService = game:GetService("SoundService")
SoundService.RolloffScale = 1 -- attenuation simulates real world
SoundService.RolloffScale = 2 -- sound attenuates twice as fast as the real world

Developers wishing to learn more about the different settings Roblox's sound engine uses should consult the FMOD documentation.

History 7

SetInputDevice

Parameters (2)
namestring
guidstring
Returns (1)
null

History 2

SetListener

Parameters (2)
listenerTypeListenerType
listenerTuple
Returns (1)
null

Sets the listener used by the client.

The first parameter is the ListenerType of the listener, the second parameter is dependent on the listener type.

  • Camera ListenerType - Does not return a listener object as Workspace.CurrentCamera is always used
  • CFrame ListenerType - The CFrame to be used
  • ObjectPosition ListenerType - The BasePart to be used
  • ObjectCFrame ListenerType - The BasePart to be used

The listener can be retrieved using SoundService:GetListener():

1
2
3
4
local SoundService = game:GetService("SoundService")
SoundService:SetListener(Enum.ListenerType.CFrame, CFrame.new(0, 0, 0))
local listenerType, listener = SoundService:GetListener()
print(listenerType, listener)

What is a listener?

The SoundService listener determines the point from which audio in the game is being 'heard' by the player. For 3D Sounds (sounds parented to a BasePart or Attachment) the listener influences the volume and left/right balance of a playing sound. Listeners have no influence on the playback of 2D sounds as they have no position of emission.

By default, the listener is set to the CurrentCamera. However, a range of different types of listeners can be used.

History 3

SetOutputDevice

Parameters (2)
namestring
guidstring
Returns (1)
null

History 2

SetRecordingDevice

Parameters (1)
deviceIndexint
Returns (1)
bool

History 2

VolumetricAudio

TypeDefault
VolumetricAudioAutomatic
This property is not scriptable. It cannot be accessed by script code.

History 3

Tags: [NotScriptable]

Removed members 1

PlayStockSound

Parameters (1)
soundSoundType
Returns (1)
void

History 3

Settings