Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Core::AudioFlowGraph Class Reference

Shared flow-graph audio runtime built on a miniaudio node graph. More...

#include <AudioFlowGraph.h>

Collaboration diagram for Engine::Core::AudioFlowGraph:

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_

Detailed Description

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.

Member Enumeration Documentation

◆ Result

Result codes; numbering mirrors the sab_* ABI (AudioBridge.h).

Enumerator
OK 
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 

Definition at line 30 of file AudioFlowGraph.h.

Constructor & Destructor Documentation

◆ AudioFlowGraph() [1/2]

Engine::Core::AudioFlowGraph::AudioFlowGraph ( )

Referenced by AudioFlowGraph(), and operator=().

Here is the caller graph for this function:

◆ ~AudioFlowGraph()

Engine::Core::AudioFlowGraph::~AudioFlowGraph ( )

◆ AudioFlowGraph() [2/2]

Engine::Core::AudioFlowGraph::AudioFlowGraph ( const AudioFlowGraph & )
delete

References AudioFlowGraph().

Here is the call graph for this function:

Member Function Documentation

◆ build()

Result Engine::Core::AudioFlowGraph::build ( uint32_t sampleRate,
uint32_t frameSize )

Decode clips and build the miniaudio node graph.

Parameters
sampleRateContext sample rate; must equal the flow's declared rate.
frameSizeGraph processing period in frames.

References sampleRate().

Here is the call graph for this function:

◆ channels()

uint32_t Engine::Core::AudioFlowGraph::channels ( ) const
nodiscard

◆ duration()

uint64_t Engine::Core::AudioFlowGraph::duration ( ) const
nodiscard

Total frames of the flow, or 0 when it loops forever.

◆ errorCode()

Result Engine::Core::AudioFlowGraph::errorCode ( ) const
nodiscard

◆ finishPlayback()

void Engine::Core::AudioFlowGraph::finishPlayback ( )

Mark playback as finished (called from the device thread when a finite, non-looping flow reaches its end).

◆ free()

void Engine::Core::AudioFlowGraph::free ( )

Release the built graph so the flow can be load()/build()ed again.

◆ isBuilt()

bool Engine::Core::AudioFlowGraph::isBuilt ( ) const
nodiscard

◆ isLoaded()

bool Engine::Core::AudioFlowGraph::isLoaded ( ) const
nodiscard

◆ isPlaying()

bool Engine::Core::AudioFlowGraph::isPlaying ( ) const
nodiscard

True while the flow is playing on the device.

◆ isSpatialized()

bool Engine::Core::AudioFlowGraph::isSpatialized ( ) const
nodiscard

◆ lastError()

const std::string & Engine::Core::AudioFlowGraph::lastError ( ) const
nodiscard

◆ load()

Result Engine::Core::AudioFlowGraph::load ( const char * flowJson,
const char * baseDir )

Parse and validate a flow JSON document (schema version 1).

Parameters
flowJsonUTF-8 flow document.
baseDirDirectory clip files / bank wavs are resolved against.
Returns
OK, or a validation result with details in lastError().

◆ name()

const std::string & Engine::Core::AudioFlowGraph::name ( ) const
nodiscard

◆ operator=()

AudioFlowGraph & Engine::Core::AudioFlowGraph::operator= ( const AudioFlowGraph & )
delete

References AudioFlowGraph().

Here is the call graph for this function:

◆ playbackPosition()

uint64_t Engine::Core::AudioFlowGraph::playbackPosition ( ) const
nodiscard

Frames consumed during the current playback session. Updated by the audio thread; clamped by callers to duration().

◆ readForPlayback()

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).

◆ render()

uint64_t Engine::Core::AudioFlowGraph::render ( float * out,
uint64_t frameCount )

Pull the next chunk of interleaved f32 PCM from the flow cursor.

Parameters
outCaller-allocated buffer of frameCount * channels() floats.
frameCountFrames requested.
Returns
Frames written; fewer than frameCount only for the final partial chunk. 0 = end of stream. On failure 0 is returned too and errorCode()/lastError() describe the problem.

◆ reset()

Result Engine::Core::AudioFlowGraph::reset ( )

Rewind the cursor to frame 0; current param values are re-applied.

◆ sampleRate()

uint32_t Engine::Core::AudioFlowGraph::sampleRate ( ) const
nodiscard

Referenced by build().

Here is the caller graph for this function:

◆ setLooping()

void Engine::Core::AudioFlowGraph::setLooping ( bool loop)

Override looping on all clip data sources (per-instance).

◆ setParam()

Result Engine::Core::AudioFlowGraph::setParam ( uint32_t settingIndex,
float value )

Apply a value (clamped to the setting range) to a setting.

Parameters
settingIndexIndex into the flow's settings array.

◆ settingCount()

uint32_t Engine::Core::AudioFlowGraph::settingCount ( ) const
nodiscard

◆ startPlayback()

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().

◆ stopPlayback()

void Engine::Core::AudioFlowGraph::stopPlayback ( )

Leave realtime playback mode.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> Engine::Core::AudioFlowGraph::impl_
private

Definition at line 147 of file AudioFlowGraph.h.


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Audio/AudioFlowGraph.h