LCOV - code coverage report
Current view: top level - src/audio/engine - analyzer_capture.h (source / functions) Coverage Total Hit
Test: merged.info Lines: 100.0 % 1 1
Test Date: 2026-06-07 15:51:50 Functions: 66.7 % 3 2

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <array>
       4              : #include <atomic>
       5              : #include <mutex>
       6              : 
       7              : #include "audio/engine/i_audio_engine.h"
       8              : 
       9              : namespace Amplitron {
      10              : 
      11              : /**
      12              :  * @brief Handles real-time capture of input and output signals for visual analyzer.
      13              :  * Satisfies Single Responsibility Principle (SRP).
      14              :  */
      15              : class AnalyzerCapture : public IAnalyzerProvider {
      16              :    public:
      17              :     static constexpr int ANALYZER_FFT_SIZE = 2048;
      18              :     static constexpr int ANALYZER_FFT_MASK = ANALYZER_FFT_SIZE - 1;
      19              :     static constexpr int ANALYZER_HOP_SIZE = 1024;
      20              : 
      21              :     AnalyzerCapture();
      22         1629 :     ~AnalyzerCapture() override = default;
      23              : 
      24              :     // IAnalyzerProvider implementation
      25              :     void set_analyzer_enabled(bool enabled) override;
      26              :     bool is_analyzer_enabled() const override;
      27              :     uint64_t get_analyzer_sequence() const override;
      28              :     bool copy_analyzer_snapshot(float* input_dest, float* output_dest,
      29              :                                 int sample_count) const override;
      30              : 
      31              :     // Audio thread capture methods
      32              :     void capture_input(const float* input, int count);
      33              :     void capture_output(const float* output, int count);
      34              : 
      35              :    private:
      36              :     std::atomic<bool> enabled_{false};
      37              : 
      38              :     // Ring buffers (written on audio thread only)
      39              :     std::array<float, ANALYZER_FFT_SIZE> capture_input_{};
      40              :     std::array<float, ANALYZER_FFT_SIZE> capture_output_{};
      41              :     int capture_index_ = 0;
      42              :     int samples_since_publish_ = 0;
      43              : 
      44              :     // Mutex-protected snapshots
      45              :     mutable std::mutex mutex_;
      46              :     std::array<float, ANALYZER_FFT_SIZE> snapshot_input_{};
      47              :     std::array<float, ANALYZER_FFT_SIZE> snapshot_output_{};
      48              :     std::atomic<uint64_t> sequence_{0};
      49              : };
      50              : 
      51              : }  // namespace Amplitron
        

Generated by: LCOV version 2.0-1