---
name: AudioStreamWriter
last_updated: 2026-11-11T22:23:24Z
inherits:
  - Instance
  - Object
type: class
memory_category: Internal
tags:
  - NotBrowsable
summary: "Writes audio samples from Luau buffers into an audio stream for custom synthesis."
---

# Class: AudioStreamWriter

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

## Description

[AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) 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](/docs/reference/engine/classes/AudioStreamWriter.md). Samples written with
[Write()](/docs/reference/engine/classes/AudioStreamWriter.md) are buffered and consumed by the audio
engine at the sample rate. Use [Space()](/docs/reference/engine/classes/AudioStreamWriter.md) to
check how many frames can be written without dropping samples.

For read-modify-write effects processing, pair an [AudioStreamReader](/docs/reference/engine/classes/AudioStreamReader.md)
with an [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) to read incoming audio, transform it in
Luau, and write the result back into the audio graph.

Note that [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) can only be used in Roblox Studio and
cannot be used in Team Create sessions.

## Properties

### Property: AudioStreamWriter.Layout

```json
{
  "type": "AudioChannelLayout",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": true,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "State",
  "capabilities": [
    "Audio"
  ]
}
```

The channel layout of the audio stream that the writer produces. This
determines how many buffers must be passed to
[Write()](/docs/reference/engine/classes/AudioStreamWriter.md). For example, a
[Stereo](/docs/reference/engine/enums/AudioChannelLayout.md) layout requires two buffers per call.

### Property: AudioStreamWriter.SampleFormat

```json
{
  "type": "AudioSampleFormat",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "State",
  "capabilities": [
    "Audio"
  ]
}
```

The sample format of the audio data stored in the internal buffer. This
property is currently read-only and is always
[Float32](/docs/reference/engine/enums/AudioSampleFormat.md).

### Property: AudioStreamWriter.SampleRate

```json
{
  "type": "int",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": false,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "State",
  "capabilities": [
    "Audio"
  ]
}
```

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

### Property: AudioStreamWriter.WindowSize

```json
{
  "type": "AudioWindowSize",
  "access": "ReadWrite",
  "security": {
    "read": "None",
    "write": "None"
  },
  "serialization": {
    "can_load": true,
    "can_save": true
  },
  "thread_safety": "ReadSafe",
  "category": "State",
  "capabilities": [
    "Audio"
  ]
}
```

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.

## Methods

### Method: AudioStreamWriter:GetConnectedWires

**Signature:** `AudioStreamWriter:GetConnectedWires(pin: string): List<Wire>`

Returns an array of [Wires](/docs/reference/engine/classes/Wire.md) that are connected to the specified
pin. [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) has one **Output** pin.

*Security: None · Thread Safety: Unsafe · Capabilities: Audio*

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `pin` | `string` |  | An input or output pin on this instance. |

**Returns:** `List<Wire>` — An array of [Wires](/docs/reference/engine/classes/Wire.md).

### Method: AudioStreamWriter:GetInputPins

**Signature:** `AudioStreamWriter:GetInputPins(): Array`

Gets the list of pins that [Wire](/docs/reference/engine/classes/Wire.md) can use in [Wire.TargetName](/docs/reference/engine/classes/Wire.md)
to connect to this instance via its [Wire.TargetInstance](/docs/reference/engine/classes/Wire.md) property.

For [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md), there are none.

*Security: None · Thread Safety: Unsafe · Capabilities: Audio*

**Returns:** `Array` — An array of strings representing valid pin names.

### Method: AudioStreamWriter:GetOutputPins

**Signature:** `AudioStreamWriter:GetOutputPins(): Array`

Gets the list of pins that [Wire](/docs/reference/engine/classes/Wire.md) can use in [Wire.SourceName](/docs/reference/engine/classes/Wire.md)
to connect to this instance via its [Wire.SourceInstance](/docs/reference/engine/classes/Wire.md) property.

For [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md), this is `Output` only.

*Security: None · Thread Safety: Unsafe · Capabilities: Audio*

**Returns:** `Array` — An array of strings representing valid pin names.

### Method: AudioStreamWriter:Space

**Signature:** `AudioStreamWriter:Space(): 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.

*Security: None · Thread Safety: Safe · Capabilities: Audio*

**Returns:** `int` — The number of frames of available space in the internal buffer.

### Method: AudioStreamWriter:Write

**Signature:** `AudioStreamWriter:Write(audioBuffer: Array): 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](/docs/reference/engine/classes/AudioStreamWriter.md). Returns
the number of frames actually written, which may be less than the buffer
length if insufficient space is available. Use
[Space()](/docs/reference/engine/classes/AudioStreamWriter.md) to check available capacity before
writing.

*Security: None · Thread Safety: Safe · Capabilities: Audio*

**Parameters:**

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `audioBuffer` | `Array` |  | An array of buffers, one per channel, containing samples to write. |

**Returns:** `int` — The number of frames actually written into the buffer.

## Events

### Event: AudioStreamWriter.WiringChanged

**Signature:** `AudioStreamWriter.WiringChanged(connected: boolean, pin: string, wire: Wire, instance: Instance)`

Event that fires after a [Wire](/docs/reference/engine/classes/Wire.md) becomes connected or disconnected,
and that [Wire](/docs/reference/engine/classes/Wire.md) is now or was previously connected to a pin on the
[AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) and to some other wirable instance.

*Security: None · Capabilities: Audio*

**Parameters:**

| Name | Type | Description |
|------|------|-------------|
| `connected` | `boolean` | Whether the instance got connected or disconnected. |
| `pin` | `string` | The pin on the [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) that the [Wire](/docs/reference/engine/classes/Wire.md) targets. |
| `wire` | `Wire` | The [Wire](/docs/reference/engine/classes/Wire.md) between the [AudioStreamWriter](/docs/reference/engine/classes/AudioStreamWriter.md) and the other instance. |
| `instance` | `Instance` | The other instance that is or was connected through the [Wire](/docs/reference/engine/classes/Wire.md). |

## Inherited Members

### From [Instance](/docs/reference/engine/classes/Instance.md)

- **Property `Archivable`** (`boolean`): Determines if an Instance and its descendants can be cloned using
- **Property `archivable`** (`boolean`):  *(deprecated, hidden)*
- **Property `Capabilities`** (`SecurityCapabilities`): The set of capabilities allowed to be used for scripts inside this
- **Property `IsInSandbox`** (`boolean`): Indicates whether the instance is inside a sandboxed container.
- **Property `Name`** (`string`): A non-unique identifier of the Instance.
- **Property `Parent`** (`Instance`): Determines the hierarchical parent of the Instance.
- **Property `PredictionMode`** (`PredictionMode`): Reflects the client-side prediction mode applied to the instance under
- **Property `RobloxLocked`** (`boolean`): A deprecated property that used to protect CoreGui objects. *(hidden)*
- **Property `Sandboxed`** (`boolean`): When enabled, the instance can only access abilities in its `Capabilities`
- **Property `UniqueId`** (`UniqueId`): A unique identifier for the instance.
- **Method `AddTag(tag: string): ()`**: Applies a tag to the instance.
- **Method `children(): Instances`**: Returns an array of the object's children. *(deprecated)*
- **Method `ClearAllChildren(): ()`**: This method destroys all of an instance's children.
- **Method `Clone(): Instance`**: Create a copy of an instance and all its descendants, ignoring instances
- **Method `clone(): Instance`**:  *(deprecated)*
- **Method `Destroy(): ()`**: Sets the Instance.Parent property to `nil`, locks the
- **Method `destroy(): ()`**:  *(deprecated)*
- **Method `FindFirstAncestor(name: string): Instance?`**: Returns the first ancestor of the Instance whose
- **Method `FindFirstAncestorOfClass(className: string): Instance?`**: Returns the first ancestor of the Instance whose
- **Method `FindFirstAncestorWhichIsA(className: string): Instance?`**: Returns the first ancestor of the Instance for whom
- **Method `FindFirstChild(name: string, recursive?: boolean): Instance?`**: Returns the first child of the Instance found with the given name.
- **Method `findFirstChild(name: string, recursive?: boolean): Instance`**:  *(deprecated)*
- **Method `FindFirstChildOfClass(className: string): Instance?`**: Returns the first child of the Instance whose
- **Method `FindFirstChildWhichIsA(className: string, recursive?: boolean): Instance?`**: Returns the first child of the Instance for whom
- **Method `FindFirstDescendant(name: string): Instance?`**: Returns the first descendant found with the given Instance.Name.
- **Method `GetActor(): Actor?`**: Returns the Actor associated with the Instance, if any.
- **Method `GetAttribute(attribute: string): Variant`**: Returns the value which has been assigned to the given attribute name.
- **Method `GetAttributeChangedSignal(attribute: string): RBXScriptSignal`**: Returns an event that fires when the given attribute changes.
- **Method `GetAttributes(): Dictionary`**: Returns a dictionary of the instance's attributes.
- **Method `GetChildren(): Instances`**: Returns an array containing all of the instance's children.
- **Method `getChildren(): Instances`**:  *(deprecated)*
- **Method `GetDebugId(scopeLength?: int): string`**: Returns a coded string of the debug ID used internally by Roblox.
- **Method `GetDescendants(): Instances`**: Returns an array containing all of the descendants of the instance.
- **Method `GetFullName(): string`**: Returns a string describing the instance's ancestry.
- **Method `GetStyled(name: string, selector: string?): Variant`**: Returns the styled or explicitly modified value of the specified property,
- **Method `GetStyledPropertyChangedSignal(property: string): RBXScriptSignal`**: Returns an event that fires when the given style property changes on the
- **Method `GetTags(): Array`**: Gets an array of all tags applied to the instance.
- **Method `HasTag(tag: string): boolean`**: Check whether the instance has a given tag.
- **Method `IsAncestorOf(descendant: Instance): boolean`**: Returns true if an Instance is an ancestor of the given
- **Method `IsDescendantOf(ancestor: Instance): boolean`**: Returns `true` if an Instance is a descendant of the given
- **Method `isDescendantOf(ancestor: Instance): boolean`**:  *(deprecated)*
- **Method `IsPropertyModified(property: string): boolean`**: Returns `true` if the value stored in the specified property is not equal
- **Method `QueryDescendants(selector: string): Instances`**: Returns an array containing all descendants of the instance that match the
- **Method `Remove(): ()`**: Sets the object's `Parent` to `nil`, and does the same for all its *(deprecated)*
- **Method `remove(): ()`**:  *(deprecated)*
- **Method `RemoveTag(tag: string): ()`**: Removes a tag from the instance.
- **Method `ResetPropertyToDefault(property: string): ()`**: Resets a property to its default value.
- **Method `SetAttribute(attribute: string, value: Variant): ()`**: Sets the attribute with the given name to the given value.
- **Method `WaitForChild(childName: string, timeOut: double): Instance`**: Returns the child of the Instance with the given name. If the
- **Event `AncestryChanged`**: Fires when the Instance.Parent property of this object or one of
- **Event `AttributeChanged`**: Fires whenever an attribute is changed on the Instance.
- **Event `ChildAdded`**: Fires after an object is parented to this Instance.
- **Event `childAdded`**:  *(deprecated)*
- **Event `ChildRemoved`**: Fires after a child is removed from this Instance.
- **Event `DescendantAdded`**: Fires after a descendant is added to the Instance.
- **Event `DescendantRemoving`**: Fires immediately before a descendant of the Instance is removed.
- **Event `Destroying`**: Fires immediately before (or is deferred until after) the instance is
- **Event `StyledPropertiesChanged`**: Fires whenever any style property is changed on the instance, including

### From [Object](/docs/reference/engine/classes/Object.md)

- **Property `ClassName`** (`string`): A read-only string representing the class this Object belongs to.
- **Property `className`** (`string`):  *(deprecated)*
- **Method `GetPropertyChangedSignal(property: string): RBXScriptSignal`**: Get an event that fires when a given property of the object changes.
- **Method `IsA(className: string): boolean`**: Returns true if an object's class matches or inherits from a given class.
- **Method `isA(className: string): boolean`**:  *(deprecated)*
- **Event `Changed`**: Fires immediately after a property of the object changes, with some