LCOV - code coverage report
Current view: top level - src/audio/engine - audio_graph_executor.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 100.0 % 5 5
Test Date: 2026-06-03 09:13:19 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "audio/engine/audio_graph.h"
       4              : #include "audio/effects/effect.h"
       5              : #include <vector>
       6              : #include <unordered_map>
       7              : #include <memory>
       8              : 
       9              : namespace Amplitron {
      10              : 
      11              : class AudioGraphExecutor {
      12              : public:
      13              :     AudioGraphExecutor();
      14         3374 :     ~AudioGraphExecutor() = default;
      15              : 
      16              :     // Allocate the memory pool ahead of time (Call this during engine initialization)
      17              :     void prepare(int sample_rate, int max_block_size, int max_nodes = 32);
      18              : 
      19              :     // Translates the AudioGraph into a flat, allocation-free execution array
      20              :     // Call this from the UI thread whenever connections change!
      21              :     void compile(const AudioGraph& graph);
      22              : 
      23              :     // Broadcast tempo/BPM down to all active nodes in the execution plan
      24              :     void update_transport_state(float bpm);
      25              : 
      26              :     // Hot-path processing (Strictly allocation-free and lock-free)
      27              :     // Adjust the pedal->process signature if your pedals process strictly in-place
      28              :     void process(const float* input, float* output, int num_samples);
      29              :     void update_mixer_gain(int node_id, int pin_index, float gain);
      30              : 
      31              : private:
      32              :     int sample_rate_ = 48000;
      33              :     int max_block_size_ = 512;
      34              :     int max_nodes_ = 32;
      35              : 
      36              :     struct InputSource {
      37              :         int buffer_index; // The pool index to read from
      38              :         float gain = 1.0f;
      39              :         int pin_index = 0;
      40              :     };
      41              : 
      42         4344 :     struct NodeExecutionStep {
      43              :         int node_id;
      44              :         int buffer_index; // The pool index this node writes to
      45              :         NodeRoutingType type;
      46              :         std::shared_ptr<Effect> pedal;
      47              :         std::vector<InputSource> input_sources; // Which buffers to sum together for the input
      48         1448 :         bool is_graph_input = false;
      49         1448 :         bool is_graph_output = false;
      50         1448 :         bool is_sink = false;
      51              :     };
      52              : 
      53              :     std::vector<NodeExecutionStep> execution_plan_;
      54              :     
      55              :     bool any_explicit_input_ = false;
      56              :     int fallback_input_node_id_ = -1;
      57              : 
      58              :     // Pre-allocated memory for routing parallel signal streams: [node_capacity][max_block_size]
      59              :     std::vector<std::vector<float>> buffer_pool_;
      60              :     
      61              :     // A dedicated temporary buffer for summing multiple incoming signals
      62              :     std::vector<float> sum_buffer_;
      63              : };
      64              : 
      65              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1