Reference API Roblox

Engine API

Website

Related

Reference API Roblox

AudioStreamWriter

Writes audio samples from Luau buffers into an audio stream for custom synthesis.

This class is not browsable. It is not visible in Studio's object browser.
Tags: [NotBrowsable]

Member index 10

HistoryMember
747Layout: AudioChannelLayout
747SampleFormat: AudioSampleFormat
747SampleRate: int
747WindowSize: AudioWindowSize
747GetConnectedWires(pin: string): Instances
747GetInputPins(): Array
747GetOutputPins(): Array
747Space(): int
747Write(audioBuffer: Array): int
747WiringChanged(connected: bool, pin: string, wire: Wire, instance: Instance)
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: 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
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

AudioStreamWriter writes audio samples from Luau buffers into an audio stream, enabling custom synthesis or effects processing. It provides a single Output pin and does not accept any input streams.

The writer maintains an internal ring buffer whose size is controlled by WindowSize. Samples written with Write() are buffered and consumed by the audio engine at the sample rate. Use Space() to check how many frames can be written without dropping samples.

For read-modify-write effects processing, pair an AudioStreamReader with an AudioStreamWriter to read incoming audio, transform it in Luau, and write the result back into the audio graph.

Note that AudioStreamWriter can only be used in Roblox Studio and cannot be used in Team Create sessions.

History 11

Members 10

GetConnectedWires

Parameters (1)
pinstring
Returns (1)
Instances

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

History 1

GetInputPins

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

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

For AudioStreamWriter, there are none.

History 1

GetOutputPins

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

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

For AudioStreamWriter, this is Output only.

History 1

Layout

TypeDefault
AudioChannelLayoutMono

The channel layout of the audio stream that the writer produces. This determines how many buffers must be passed to Write(). For example, a Stereo layout requires two buffers per call.

History 1

SampleFormat

TypeDefault
AudioSampleFormatFloat32

The sample format of the audio data stored in the internal buffer. This property is currently read-only and is always Float32.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

SampleRate

TypeDefault
int48000

The sample rate of the audio data, in Hertz. This property is currently read-only and is always 48000.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

Space

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

Returns the number of frames that can currently be written to the internal buffer without dropping samples. Use this to avoid writing more data than the buffer can hold. The available space increases as the audio engine consumes buffered samples.

History 1

WindowSize

TypeDefault
AudioWindowSizeMedium

Controls the size of the internal ring buffer that stores audio samples before they are consumed by the audio engine. Larger windows allow more samples to be buffered ahead of time, reducing the chance of underruns, but increase latency. Smaller windows reduce latency but require more frequent writes.

History 1

WiringChanged

Parameters (4)
connectedbool
pinstring
wireWire
instanceInstance

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

History 1

Write

Parameters (1)
audioBufferArray
Returns (1)
int

Writes audio samples into the internal buffer. The audio engine consumes these samples at the configured sample rate and outputs them through the Output pin. The number of buffers in the array must match the number of channels specified by Layout. Returns the number of frames actually written, which may be less than the buffer length if insufficient space is available. Use Space() to check available capacity before writing.

This function has a custom internal state. It may behave in a non-standard way.

History 1

Tags: [CustomLuaState]

Settings