AudioStreamWriter
Writes audio samples from Luau buffers into an audio stream for custom synthesis.
| Memory category | Internal |
|---|
Member index 10
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
- 747 Add WiringChanged
- 747 Add Write
- 747 Add Space
- 747 Add GetOutputPins
- 747 Add GetInputPins
- 747 Add GetConnectedWires
- 747 Add WindowSize
- 747 Add SampleRate
- 747 Add SampleFormat
- 747 Add Layout
- 747 Add AudioStreamWriter
Members 10
GetConnectedWires
| Parameters (1) | ||
|---|---|---|
| pin | string | |
| Returns (1) | ||
| Instances | ||
Returns an array of Wires that are connected to the specified pin. AudioStreamWriter has one Output pin.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add GetConnectedWires
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.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add GetInputPins
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.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add GetOutputPins
Layout
| Type | Default | |
|---|---|---|
| AudioChannelLayout | Mono | |
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.
| Thread safety | ReadSafe |
|---|---|
| Category | State |
| Loaded/Saved | true |
SampleFormat
| Type | Default | |
|---|---|---|
| AudioSampleFormat | Float32 | |
The sample format of the audio data stored in the internal buffer. This property is currently read-only and is always Float32.
| Thread safety | ReadSafe |
|---|---|
| Category | State |
| Loaded/Saved | false/true |
History 1
- 747 Add SampleFormat
SampleRate
| Type | Default | |
|---|---|---|
| int | 48000 | |
The sample rate of the audio data, in Hertz. This property is currently
read-only and is always 48000.
| Thread safety | ReadSafe |
|---|---|
| Category | State |
| Loaded/Saved | false/true |
History 1
- 747 Add SampleRate
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.
| Thread safety | Safe |
|---|
WindowSize
| Type | Default | |
|---|---|---|
| AudioWindowSize | Medium | |
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.
| Thread safety | ReadSafe |
|---|---|
| Category | State |
| Loaded/Saved | true |
History 1
- 747 Add WindowSize
WiringChanged
| Parameters (4) | |
|---|---|
| connected | bool |
| 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 AudioStreamWriter and to some other wirable instance.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add WiringChanged
Write
| Parameters (1) | ||
|---|---|---|
| audioBuffer | Array | |
| 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.
| Thread safety | Safe |
|---|