AudioStreamGeneratorPlayback
Stereo PCM queue for one generator playback.
Obtain this object from a started AudioStreamPlayer using AudioStreamGenerator. Each Vector2 frame contains left and right channels, not time and frequency.
GetFramesAvailable reports writable space. PushBuffer accepts the entire block or rejects it; its bool reports queue acceptance, not playback completion. When input runs out, the mixer inserts zeros and increments GetSkips.
ClearBuffer is allowed only on inactive playback. The generator does not implement ordinary Seek behavior and is not a ready-made microphone/network stream. Use one coordinated data producer.
Complete C# example and troubleshooting.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Methods7
CanPushBufferbool
public bool CanPushBuffer(int amount);Checks whether writable space can hold the requested number of stereo frames. This compares capacity; it neither reserves space nor validates data. Use one coordinated producer.
| Name | Type | Default |
|---|---|---|
amount | int | — |
amountNonnegative stereo-frame count to check. This is compared with free space, not validated as a protocol length.
booltrue when the requested frame count fits now; false when writable capacity is smaller.
ClearBuffervoid
public void ClearBuffer();Clears the queue only on inactive playback and resets its mixed-time counter. During playback the native implementation reports a diagnostic and does not clear it. Do not use this as a seek operation; it does not reset GetSkips.
GetFramesAvailableint
public int GetFramesAvailable();Returns the number of stereo frames currently writable. This is free space, not the number of unplayed frames. It can grow as the mixer consumes audio.
intWritable stereo-frame capacity. Zero means the queue is full.
GetSkipsint
public int GetSkips();Returns the number of internal mix underruns where missing PCM was replaced with zeros. This counts neither missing audio frames nor game frames. Starting playback resets the counter.
intPCM underrun-event count since playback last started; growth indicates a refill problem.
PushBuffer2 overloads
public bool PushBuffer(Vector2[] frames);Copies normalized stereo frames into the queue. If the entire block does not fit, returns false without a partial write. Success means queued, not already played. Preserve oscillator phase or decoder state across blocks.
| Name | Type | Default |
|---|---|---|
frames | Vector2[] | — |
framesArray or span of stereo frames: X is left, Y is right. Element count is frame count, not the combined sample count of both channels. Supply finite values at a suitable level.
booltrue when the entire block is queued; false when it does not fit. No partial accepted-frame count is returned.
public bool PushBuffer(ReadOnlySpan<Vector2> frames);Copies normalized stereo frames into the queue. If the entire block does not fit, returns false without a partial write. Success means queued, not already played. Preserve oscillator phase or decoder state across blocks.
| Name | Type | Default |
|---|---|---|
frames | ReadOnlySpan<Vector2> | — |
framesArray or span of stereo frames: X is left, Y is right. Element count is frame count, not the combined sample count of both channels. Supply finite values at a suitable level.
booltrue when the entire block is queued; false when it does not fit. No partial accepted-frame count is returned.
PushFramebool
public bool PushFrame(Vector2 frame);Appends one stereo frame: Vector2.X is left, Y is right. Returns false when the queue is full. For many frames, use PushBuffer blocks instead of one call per frame.
| Name | Type | Default |
|---|---|---|
frame | Vector2 | — |
frameOne normalized stereo frame. X/Y are channel amplitudes, not time and frequency; control finiteness and signal level.
booltrue after queuing the frame; false if no writable slot was available.