IAudioGenerator
A procedural sound source: C++ writes the samples itself, pulled by the audio thread at the device's native rate. Use it where a MetaSound graph is the wrong tool (a physical model, an engine or wind synthesizer driven by gameplay state) and the clip-based AudioSource has nothing to play.
- Module
- Audio
- Header
#include "Audio/AudioGenerator.h"- Namespace
Mowo
THREADING CONTRACT. Render, OnStart, OnStop and Reset all run on the audio thread, inside the device callback. They must never block, never allocate, never take a lock and never call into the engine's game-thread APIs: one slow block is an audible dropout for the whole mix. Preallocate in the constructor or in OnStart's caller side; read live control values from a TAudioParamBlock the game thread fills (Render takes a snapshot per block, so a change lands on the next block boundary; smooth it inside Render if a jump would click).
Constructors
| Signature | Name | Description |
|---|---|---|
virtual ~IAudioGenerator() = default | ~IAudioGenerator |
Public functions
| Returns | Name | Description |
|---|---|---|
void | Render | Fill frames interleaved frames of channels floats at sampleRate. |
void | OnStart | The first block after the voice was played (or played again after Stop). |
void | OnStop | The first block after the voice was stopped; no Render follows until the next OnStart. |
void | Reset | Back to the initial state (phases, filters, seeds). |
Function details
~IAudioGenerator
virtual ~IAudioGenerator() = defaultRender
virtual void Render(float* interleaved, uint32_t frames, uint32_t channels, uint32_t sampleRate) = 0Fill frames interleaved frames of channels floats at sampleRate. The buffer is zeroed first, so a generator may add into it; it must write finite values (a NaN or infinity is replaced by silence on the way out).
OnStart
virtual void OnStart(uint32_t channels, uint32_t sampleRate)The first block after the voice was played (or played again after Stop).
OnStop
virtual void OnStop()The first block after the voice was stopped; no Render follows until the next OnStart. Also delivered when the voice shuts down while running.
Reset
virtual void Reset()Back to the initial state (phases, filters, seeds). Applied at the start of the next block, so a Render never sees it half way.