|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Shared flow-graph audio runtime built on a miniaudio node graph. More...
#include <AudioFlowGraph.h>
Public Types | |
| enum class | Result { OK = 0 , INVALID_ARG , NO_MEMORY , INVALID_JSON , SCHEMA , UNKNOWN_NODE , UNKNOWN_PARAM , BAD_LINK , BAD_CLIP , CHANNELS , MULTIPLE_OUTPUTS , DUP_SETTING , RATE_MISMATCH , DECODE , DEVICE , INVALID_STATE , SPATIAL_UNSUPPORTED , SA , INTERNAL } |
| Result codes; numbering mirrors the sab_* ABI (AudioBridge.h). More... | |
Public Member Functions | |
| AudioFlowGraph () | |
| ~AudioFlowGraph () | |
| AudioFlowGraph (const AudioFlowGraph &)=delete | |
| AudioFlowGraph & | operator= (const AudioFlowGraph &)=delete |
| Result | load (const char *flowJson, const char *baseDir) |
| Parse and validate a flow JSON document (schema version 1). | |
| Result | build (uint32_t sampleRate, uint32_t frameSize) |
| Decode clips and build the miniaudio node graph. | |
| Result | setParam (uint32_t settingIndex, float value) |
| Apply a value (clamped to the setting range) to a setting. | |
| uint64_t | render (float *out, uint64_t frameCount) |
| Pull the next chunk of interleaved f32 PCM from the flow cursor. | |
| Result | reset () |
| Rewind the cursor to frame 0; current param values are re-applied. | |
| Result | startPlayback () |
| Enter realtime playback mode for this flow. Rewinds to frame 0 and marks the flow as playing. Offline render and reset are then rejected (INVALID_STATE) until stopPlayback(). | |
| void | stopPlayback () |
| Leave realtime playback mode. | |
| void | setLooping (bool loop) |
| Override looping on all clip data sources (per-instance). | |
| void | finishPlayback () |
| Mark playback as finished (called from the device thread when a finite, non-looping flow reaches its end). | |
| bool | isPlaying () const |
| True while the flow is playing on the device. | |
| uint64_t | readForPlayback (float *out, uint64_t frameCount) |
| Pull the next chunk of interleaved PCM for the device thread. Only valid while the flow is playing; the graph keeps producing silence after its sources are exhausted (looping or not). | |
| uint64_t | playbackPosition () const |
| Frames consumed during the current playback session. Updated by the audio thread; clamped by callers to duration(). | |
| uint64_t | duration () const |
| Total frames of the flow, or 0 when it loops forever. | |
| void | free () |
| Release the built graph so the flow can be load()/build()ed again. | |
| bool | isBuilt () const |
| bool | isLoaded () const |
| bool | isSpatialized () const |
| uint32_t | channels () const |
| uint32_t | sampleRate () const |
| const std::string & | name () const |
| uint32_t | settingCount () const |
| const std::string & | lastError () const |
| Result | errorCode () const |
Private Attributes | |
| std::unique_ptr< Impl > | impl_ |
Shared flow-graph audio runtime built on a miniaudio node graph.
Parses the audio-flow JSON document, builds the node graph, and offers offline rendering (a deterministic streaming cursor), parameter control and rewinding. The exact same sources are compiled into the engine and into the schnee_audio C ABI bridge so Blender preview, exporter bake and engine runtime all share one implementation.
Lifecycle: load() -> parse + validate the flow JSON (no audio resources touched) build() -> decode clips and construct the miniaudio node graph render()/setParam()/reset() while built free() -> release the graph; the object can be load()/build()ed again
Not thread-safe for concurrent use of one instance; independent instances may run on different threads.
Definition at line 27 of file AudioFlowGraph.h.
|
strong |
Result codes; numbering mirrors the sab_* ABI (AudioBridge.h).
Definition at line 30 of file AudioFlowGraph.h.
| Engine::Core::AudioFlowGraph::AudioFlowGraph | ( | ) |
| Engine::Core::AudioFlowGraph::~AudioFlowGraph | ( | ) |
|
delete |
| Result Engine::Core::AudioFlowGraph::build | ( | uint32_t | sampleRate, |
| uint32_t | frameSize ) |
Decode clips and build the miniaudio node graph.
| sampleRate | Context sample rate; must equal the flow's declared rate. |
| frameSize | Graph processing period in frames. |
References sampleRate().
|
nodiscard |
|
nodiscard |
Total frames of the flow, or 0 when it loops forever.
|
nodiscard |
| void Engine::Core::AudioFlowGraph::finishPlayback | ( | ) |
Mark playback as finished (called from the device thread when a finite, non-looping flow reaches its end).
| void Engine::Core::AudioFlowGraph::free | ( | ) |
Release the built graph so the flow can be load()/build()ed again.
|
nodiscard |
|
nodiscard |
|
nodiscard |
True while the flow is playing on the device.
|
nodiscard |
|
nodiscard |
| Result Engine::Core::AudioFlowGraph::load | ( | const char * | flowJson, |
| const char * | baseDir ) |
Parse and validate a flow JSON document (schema version 1).
| flowJson | UTF-8 flow document. |
| baseDir | Directory clip files / bank wavs are resolved against. |
|
nodiscard |
|
delete |
|
nodiscard |
Frames consumed during the current playback session. Updated by the audio thread; clamped by callers to duration().
| uint64_t Engine::Core::AudioFlowGraph::readForPlayback | ( | float * | out, |
| uint64_t | frameCount ) |
Pull the next chunk of interleaved PCM for the device thread. Only valid while the flow is playing; the graph keeps producing silence after its sources are exhausted (looping or not).
| uint64_t Engine::Core::AudioFlowGraph::render | ( | float * | out, |
| uint64_t | frameCount ) |
Pull the next chunk of interleaved f32 PCM from the flow cursor.
| out | Caller-allocated buffer of frameCount * channels() floats. |
| frameCount | Frames requested. |
| Result Engine::Core::AudioFlowGraph::reset | ( | ) |
Rewind the cursor to frame 0; current param values are re-applied.
|
nodiscard |
| void Engine::Core::AudioFlowGraph::setLooping | ( | bool | loop | ) |
Override looping on all clip data sources (per-instance).
| Result Engine::Core::AudioFlowGraph::setParam | ( | uint32_t | settingIndex, |
| float | value ) |
Apply a value (clamped to the setting range) to a setting.
| settingIndex | Index into the flow's settings array. |
|
nodiscard |
| Result Engine::Core::AudioFlowGraph::startPlayback | ( | ) |
Enter realtime playback mode for this flow. Rewinds to frame 0 and marks the flow as playing. Offline render and reset are then rejected (INVALID_STATE) until stopPlayback().
| void Engine::Core::AudioFlowGraph::stopPlayback | ( | ) |
Leave realtime playback mode.
|
private |
Definition at line 147 of file AudioFlowGraph.h.