AudioStreamReader
Reads audio samples from a connected audio stream into Luau buffers for custom analysis.
| Memory category | Internal |
|---|
Member index 10
Description
AudioStreamReader reads audio samples from a connected audio stream into Luau buffers, enabling custom analysis such as beat detection, pitch detection, or spectral processing. It provides a single Input pin and does not produce any output streams.
The reader maintains an internal ring buffer whose size is controlled by WindowSize. Incoming audio accumulates in the buffer and can be consumed with Read() or observed non-destructively with Peek().
Note that AudioStreamReader can only be used in Roblox Studio and cannot be used in Team Create sessions.
History 11
- 747 Add WiringChanged
- 747 Add Read
- 747 Add Peek
- 747 Add GetOutputPins
- 747 Add GetInputPins
- 747 Add GetConnectedWires
- 747 Add WindowSize
- 747 Add SampleRate
- 747 Add SampleFormat
- 747 Add Layout
- 747 Add AudioStreamReader
Members 10
GetConnectedWires
| Parameters (1) | ||
|---|---|---|
| pin | string | |
| Returns (1) | ||
| Instances | ||
Returns an array of Wires that are connected to the specified pin. AudioStreamReader has one Input 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 AudioStreamReader, this is Input only.
| 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 AudioStreamReader, there are none.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add GetOutputPins
Layout
| Type | Default | |
|---|---|---|
| AudioChannelLayout | Mono | |
The channel layout of the audio stream that the reader expects. This determines how many buffers must be passed to Read() and Peek(). For example, a Stereo layout requires two buffers per call.
| Thread safety | ReadSafe |
|---|---|
| Category | State |
| Loaded/Saved | true |
Peek
| Parameters (1) | ||
|---|---|---|
| into | Array | |
| Returns (1) | ||
| int | ||
Reads audio samples from the internal buffer without consuming them. Unlike Read(), peeked samples remain in the buffer and will be returned again on subsequent calls. This is useful for overlapping analysis windows. 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 data is available.
| Thread safety | Safe |
|---|
Read
| Parameters (1) | ||
|---|---|---|
| into | Array | |
| Returns (1) | ||
| int | ||
Reads audio samples from the internal buffer and removes them, advancing the read position. 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 data is available.
| Thread safety | Safe |
|---|
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
WindowSize
| Type | Default | |
|---|---|---|
| AudioWindowSize | Medium | |
Controls the size of the internal ring buffer that accumulates audio samples. Larger windows store more audio history, allowing larger reads, but consume more memory. Smaller windows reduce latency but may overflow sooner if reads are infrequent.
| 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 AudioStreamReader and to some other wirable instance.
| Thread safety | Unsafe |
|---|
History 1
- 747 Add WiringChanged