reckfellENGINE

AudioStreamGenerator

Stream resource for programmatically supplied PCM.

On this page
class AudioStreamGeneratorReckfellSharpInherits AudioStream

Assign the resource to AudioStreamPlayer, start the player and obtain AudioStreamGeneratorPlayback. Regularly supply stereo frames through PushBuffer; the generator does not synthesize sound itself.

Set MixRateMode, source rate and BufferLength before creating playback. Oscillator pitch comes from your phase increment; MixRate supplies the PCM source-frame rate only in Custom mode. The mixer can resample to the device rate.

Refill according to writable space, preserve phase across blocks and monitor GetSkips. Queue size is not total output latency. Using C# alone is not a reason to automatically lower the rate: measure your generator on the target system.

Complete C# example and troubleshooting.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

AudioStreamGeneratorConstructor
# AudioStreamGenerator
C#
public AudioStreamGenerator();

Creates a generator resource with Custom mode, MixRate=44100 and BufferLength=0.5 seconds. It neither synthesizes PCM nor starts playback itself; use a player and fill its playback buffer.

Properties3

BufferLengthProperty
# BufferLength
C#
public float BufferLength { get; set; }

Requested queue duration in seconds when playback is created. Ring-buffer sizing rounds capacity; this is not exact device output latency. A longer queue tolerates refill delays but can increase control latency. Configure before creating playback.

MixRateProperty
# MixRate
C#
public float MixRate { get; set; }

Source PCM frames per second in Custom mode only; defaults to 44100. This is neither oscillator frequency nor a command to change the device rate. The setter stores its value without enforcing the Inspector range: validate a finite positive rate before creating playback.

MixRateModeProperty
# MixRateMode
C#
public AudioStreamGenerator.AudioStreamGeneratorMixRate MixRateMode { get; set; }

Selects source PCM rate: Custom uses MixRate, Output uses AudioServer output rate, Input uses its input rate. Input neither enables a microphone nor feeds microphone data into the queue. Max is an enum sentinel, not a usable mode.

Methods6

GetBufferLengthfloat
# GetBufferLength
C#
public float GetBufferLength();

Reads the BufferLength setting. This is requested duration, not actual queued audio or measured latency.

Returns float

Configured BufferLength in seconds, not queue size in frames.

GetMixRatefloat
# GetMixRate
C#
public float GetMixRate();

Returns the stored custom MixRate. In Output/Input modes the effective source rate comes from AudioServer, so this is not a general effective-rate query.

Returns float

Stored custom MixRate in frames/second; used as the rate provider in Custom mode.

GetMixRateModeAudioStreamGenerator.AudioStreamGeneratorMixRate
# GetMixRateMode
C#
public AudioStreamGenerator.AudioStreamGeneratorMixRate GetMixRateMode();

Returns the MixRateMode setting that selects the generator’s source-rate provider.

Returns AudioStreamGenerator.AudioStreamGeneratorMixRate

Current mode selecting the generator’s source rate.

SetBufferLengthvoid
# SetBufferLength
C#
public void SetBufferLength(float seconds);

Sets BufferLength for subsequent playback creation. The setter does not recreate an existing playback’s queue. Validate a finite positive duration and reasonable memory use.

Parameters
NameTypeDefault
secondsfloat—
seconds

Finite positive duration in seconds. Validate before playback creation; a very large queue requires corresponding memory.

SetMixRatevoid
# SetMixRate
C#
public void SetMixRate(float hz);

Stores custom MixRate for Custom mode. The generation formula must use that same source frame rate. Do not change it in a running stream without coordinated stopping and reconfiguration.

Parameters
NameTypeDefault
hzfloat—
hz

Finite positive source PCM rate in frames/second. Applies in Custom mode and must match producer calculations.

SetMixRateModevoid
# SetMixRateMode
C#
public void SetMixRateMode(AudioStreamGenerator.AudioStreamGeneratorMixRate mode);

Sets MixRateMode. Selecting Output/Input does not fill the PCM buffer automatically; the producer must still supply data at the matching rate.

Parameters
NameTypeDefault
modeAudioStreamGenerator.AudioStreamGeneratorMixRate—
mode

Output, Input or Custom. Do not pass Max or arbitrary enum values.

AudioStreamGenerator.AudioStreamGeneratorMixRate

ValueDescription
Custom = 2

Custom mixing rate, specified by AudioStreamGenerator.MixRate.

Input = 1

Current AudioServer input mixing rate.

Max = 3

Maximum value for the mixing rate mode enum.

Output = 0

Current AudioServer output mixing rate.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.