Roblox UtilitiesDevlHub Roblox Documentation

Class

AudioAnalyzer

Inherits
Instance › Object
Memory category
Internal

Takes measurements from audio streams that are connected to it via one or more Wires.

AudioAnalyzer takes measurements from audio streams that are wired to it through Wire. It provides a single Input pin but does not produce any output streams. Note that all audio processing is disabled on the server in order to conserve resources; Properties and methods of AudioAnalyzer return empty or zero results when used from server scripts.

Properties 4#

PeakLevelfloatThe loudest volume observed during the last audio buffer.ReadSafeReadOnlyNotReplicated
RmsLevelfloatThe root-mean-square average volume observed during the last audio buffer.ReadSafeReadOnlyNotReplicated
SpectrumEnabledbooleanEnables usage of GetSpectrum.ReadSafe
WindowSizeAudioWindowSizeControls the resolution and timeliness of GetSpectrum.ReadSafe

PeakLevel: float#

ReadOnlyNotReplicatedReadSafe

The loudest volume observed during the last audio buffer. This property changes more often than the framerate and does not fire changed events. On the server, this property is always 0.

RmsLevel: float#

ReadOnlyNotReplicatedReadSafe

The root-mean-square average volume observed during the last audio buffer. This property is generally more stable than PeakLevel but it may not capture momentary volume spikes. This property changes more often than the framerate and does not fire changed events. On the server, this property is always 0.

SpectrumEnabled: boolean#

ReadSafe

Enables usage of GetSpectrum(). If false, GetSpectrum() returns an empty array, but the CPU overhead of the AudioAnalyzer is dramatically reduced. This means that if you are only analyzing the volume of an audio stream, you can disable this property to improve performance.

WindowSize: AudioWindowSize#

ReadSafe

Controls the size of arrays returned by GetSpectrum(). Larger windows contain more data (so more-accurate frequency responses) but change less often.

Methods 4#

GetConnectedWiresReturns an array of Wires that are connected to the specified pin.
GetInputPinsGets the list of pins that Wire can use in Wire.TargetName to connect to this instance via its Wire.TargetInstance property.
GetOutputPinsGets the list of pins that Wire can use in Wire.SourceName to connect to this instance via its Wire.SourceInstance property.
GetSpectrumReturns the frequency spectrum of the last audio buffer.CustomLuaState

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

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

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

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 AudioAnalyzer, this is Input only.

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

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 AudioAnalyzer, there are none.

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

GetSpectrum(): Array#

CustomLuaState

Returns the frequency spectrum of the last audio buffer, as an array of numbers. The elements of the array are root-mean-square volume levels, evenly spaced from 0 hertz to 24,000 hertz. If any of the analyzer's inputs come from an AudioDeviceInput, or this method is used from a server script, it returns an empty array.

Returns
  • Array — A table of numbers representing the amplitude levels of various frequencies of audio within the last buffer, or an empty table if a spectrum cannot be obtained.

Events 1#

WiringChangedFires when another instance is connected to or disconnected from the AudioAnalyzer 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 AudioAnalyzer and to some other wirable instance.

NameTypeDefaultDescription
connectedbooleanWhether the instance got connected or disconnected.
pinstringThe pin on the AudioAnalyzer that the Wire targets.
wireWireThe Wire between the AudioAnalyzer 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