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

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <memory>
       4              : #include <string>
       5              : #include <vector>
       6              : 
       7              : namespace Amplitron {
       8              : 
       9              : // Forward declaration of your existing base pedal agent interface
      10              : class Effect;
      11              : 
      12              : enum class NodeRoutingType {
      13              :   StandardEffect,
      14              :   Splitter,
      15              :   Mixer,
      16              :   MergeSum = Mixer
      17              : };
      18              : 
      19         4175 : struct DSPNode {
      20              :   int id;
      21              :   std::string name;
      22              :   NodeRoutingType routing_type;
      23              :   std::shared_ptr<Effect> pedal;
      24              : 
      25              :   std::vector<int> input_pin_ids;
      26              :   std::vector<int> output_pin_ids;
      27              : 
      28         1554 :   bool is_graph_input = false;
      29         1554 :   bool is_graph_output = false;
      30         1554 :   bool is_reachable = true;
      31              : 
      32         1554 :   float x = 0.0f;
      33         1554 :   float y = 0.0f;
      34              : 
      35              :   std::vector<float> input_gains; // Gain for each input pin (Mixer only)
      36              : };
      37              : 
      38              : struct GraphLink {
      39              :   int id;
      40              :   int source_pin_id; // Mapping from Output Pin
      41              :   int dest_pin_id;   // Mapping to Input Pin
      42              : };
      43              : 
      44              : class AudioGraph {
      45              : public:
      46         3961 :   AudioGraph() = default;
      47         3166 :   ~AudioGraph() = default;
      48              : 
      49              :   // Graph Construction Interface
      50              :   int add_node(const std::string &name, NodeRoutingType type,
      51              :                std::shared_ptr<Effect> pedal = nullptr, int num_inputs = 0);
      52              :   bool remove_node(int node_id);
      53              :   int add_link(int source_pin_id, int dest_pin_id);
      54              :   bool remove_link(int link_id);
      55              : 
      56              :   void set_node_as_input(int node_id, bool is_input);
      57              :   void set_node_as_output(int node_id, bool is_output);
      58              :   void set_node_position(int node_id, float x, float y);
      59              : 
      60              :   // Topological Order & Loop Validation Core
      61              :   bool rebuild_topology();
      62              : 
      63              :   // For Undo/Redo System (forces cache reload)
      64              :   void restore_node(const DSPNode& node);
      65              :   void restore_link(const GraphLink& link);
      66              : 
      67              :   // Dynamic Mixer API
      68              :   bool add_input_pin(int node_id);
      69              :   bool remove_input_pin(int node_id, int pin_id = -1);
      70              :   void set_mixer_input_gain(int node_id, size_t pin_index, float gain);
      71              :   void restore_input_pin(int node_id, int pin_id, int index, float gain);
      72              : 
      73              :   // Dynamic Splitter API
      74              :   bool add_output_pin(int node_id);
      75              :   bool remove_output_pin(int node_id, int pin_id = -1);
      76              :   void restore_output_pin(int node_id, int pin_id, int index);
      77              : 
      78              :   // Accessors
      79         2563 :   const std::vector<int> &get_sorted_nodes() const { return sorted_node_ids_; }
      80         9244 :   const std::vector<DSPNode> &get_nodes() const { return nodes_; }
      81         2860 :   const std::vector<GraphLink> &get_links() const { return links_; }
      82              : 
      83              :   int get_node_from_pin(int pin_id) const;
      84              :   const DSPNode *find_node(int node_id) const;
      85              : 
      86              : private:
      87              :   size_t get_node_index(int node_id) const;
      88              : 
      89          795 :   int next_id_ = 1;
      90              :   std::vector<DSPNode> nodes_;
      91              :   std::vector<GraphLink> links_;
      92              :   std::vector<int> sorted_node_ids_;
      93              : };
      94              : 
      95              : } // namespace Amplitron
        

Generated by: LCOV version 2.0-1