# danilodsp/rt-aep architecture

> Architecture diagram of the GitHub repository danilodsp/rt-aep, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danilodsp/rt-aep
- Repository: https://github.com/danilodsp/rt-aep

## Overview

##### Project Type and Purpose
- This is a native C++17 desktop application: a Real-Time Audio Effects Processor (RT-AEP).
- It captures live audio via PortAudio, runs it through a chain of DSP effects, displays a visualization, and lets the user tweak parameters in real time using Dear ImGui.

##### High-Level Components
a. Audio I/O Layer
- PortAudio (external library)
- Responsible for capturing and outputting the audio stream
b. Core Audio Engine
- AudioEngine (AudioEngine.hpp/cpp)
- Coordinates audio callback, buffer management, and dispatch to effects
c. Effect Chain
- EffectChain (EffectChain.hpp/cpp)
- A container of individual AudioEffect subclasses (Distortion, Echo, Gain, PitchShifter, Reverb)
- Each effect implements processSample or processBuffer
d. GUI Layer
- GUIManager (GUIManager.hpp/cpp) under gui/
- Built using Dear ImGui
- Renders sliders, toggles, and binds to AudioEngine/EffectChain parameters
e. Visualization Layer
- Visualizer (Visualizer.hpp/cpp) under visualization/
- Pulls audio buffer snapshots from AudioEngine and renders waveforms/spectra
f. Build & Configuration
- CMakeLists.txt (root, src/, gui/)
- Defines targets, finds PortAudio, sets include paths
g. External Dependencies
- PortAudio (audio backend)
- Dear ImGui (GUI framework, included via external or submodule)

##### Relationships and Data Flows
- Audio Input → PortAudio Callback → AudioEngine → EffectChain → [ Distortion, Echo, … ] → AudioEngine → PortAudio Output.
- GUIManager ←→ AudioEngine/EffectChain (parameter control bi-directional).
- AudioEngine → Visualizer (buffer tap for real-time display).
- CMake orchestrates building of all modules with correct linkages.

##### Architectural Patterns & Principles
- Modular DSP pipeline (Chain of Responsibility pattern for effects).
- Clear separation of concerns:
- Audio I/O vs. DSP vs. UI vs. Visualization
- Dependency Injection: GUI and Visualizer reference AudioEngine interfaces rather than static globals.
- Single responsibility: Each effect class does one thing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Configuration"
        CMakeRoot["CMakeLists.txt"]:::build
        SrcCMake["src/CMakeLists.txt"]:::build
        GuiCMake["gui/CMakeLists.txt"]:::build
        CMakeRoot --> SrcCMake
        CMakeRoot --> GuiCMake
    end

    subgraph "External Dependencies"
        PortAudio["PortAudio"]:::external
        ImGui["Dear ImGui"]:::external
    end

    subgraph "Desktop Application"
        subgraph "Audio I/O Layer"
            Main["main.cpp"]:::app
        end

        subgraph "Core Audio Engine"
            AudioEngineH["AudioEngine.hpp"]:::core
            AudioEngineCpp["AudioEngine.cpp"]:::core
            AudioEngineH --> AudioEngineCpp
        end

        subgraph "Effect Chain"
            EffectChainH["EffectChain.hpp"]:::core
            EffectChainCpp["EffectChain.cpp"]:::core
            EffectChainH --> EffectChainCpp
            subgraph "Effects"
                AudioEffectH["AudioEffect.hpp"]:::core
                DistH["DistortionEffect.hpp"]:::core
                DistCpp["DistortionEffect.cpp"]:::core
                EchoH["EchoEffect.hpp"]:::core
                EchoCpp["EchoEffect.cpp"]:::core
                GainH["GainEffect.hpp"]:::core
                GainCpp["GainEffect.cpp"]:::core
                PitchH["PitchShifterEffect.hpp"]:::core
                PitchCpp["PitchShifterEffect.cpp"]:::core
                ReverbH["ReverbEffect.hpp"]:::core
                ReverbCpp["ReverbEffect.cpp"]:::core

                AudioEffectH --> DistH
                AudioEffectH --> EchoH
                AudioEffectH --> GainH
                AudioEffectH --> PitchH
                AudioEffectH --> ReverbH

                DistH --> DistCpp
                EchoH --> EchoCpp
                GainH --> GainCpp
                PitchH --> PitchCpp
                ReverbH --> ReverbCpp
            end
            EffectChainH --> AudioEffectH
        end

        subgraph "GUI Layer"
            GUIH["GUIManager.hpp"]:::ui
            GUICpp["GUIManager.cpp"]:::ui
            ImGuiIni["imgui.ini"]:::ui
            GUIH --> GUICpp
        end

        subgraph "Visualization Layer"
            VizH["Visualizer.hpp"]:::ui
            VizCpp["Visualizer.cpp"]:::ui
            VizReadme["README.md"]:::ui
            VizH --> VizCpp
        end

        PortAudio -->|"audio callback"| Main
        Main -->|"real-time thread"| AudioEngineH
        AudioEngineH -->|"invokes"| EffectChainH
        EffectChainH -->|"processSample"| DistH
        EffectChainH --> DistH
        EffectChainH --> EchoH
        EffectChainH --> GainH
        EffectChainH --> PitchH
        EffectChainH --> ReverbH
        AudioEngineCpp -->|"PCM frames"| PortAudio

        GUIH <-->|"control events"| AudioEngineH
        GUIH <-->|"control events"| EffectChainH

        AudioEngineH -->|"buffer snapshots"| VizH
    end

    classDef core fill:#D6E9FE,stroke:#4A90E2,color:#000;
    classDef ui fill:#E8F6E8,stroke:#3C763D,color:#000;
    classDef external fill:#E0E0E0,stroke:#666,color:#000;
    classDef build fill:#FCF8E3,stroke:#8A6D3B,color:#000;
    classDef app fill:#F5F5F5,stroke:#AAA,color:#000;

    click Main "https://github.com/danilodsp/rt-aep/blob/main/main.cpp"
    click CMakeRoot "https://github.com/danilodsp/rt-aep/blob/main/CMakeLists.txt"
    click SrcCMake "https://github.com/danilodsp/rt-aep/blob/main/src/CMakeLists.txt"
    click GuiCMake "https://github.com/danilodsp/rt-aep/blob/main/gui/CMakeLists.txt"
    click PortAudio "https://github.com/danilodsp/rt-aep/tree/main/external/"
    click ImGui "https://github.com/danilodsp/rt-aep/tree/main/external/"
    click AudioEngineH "https://github.com/danilodsp/rt-aep/blob/main/include/AudioEngine.hpp"
    click AudioEngineCpp "https://github.com/danilodsp/rt-aep/blob/main/src/AudioEngine.cpp"
    click EffectChainH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/EffectChain.hpp"
    click EffectChainCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/EffectChain.cpp"
    click AudioEffectH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/AudioEffect.hpp"
    click DistH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/DistortionEffect.hpp"
    click DistCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/DistortionEffect.cpp"
    click EchoH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/EchoEffect.hpp"
    click EchoCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/EchoEffect.cpp"
    click GainH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/GainEffect.hpp"
    click GainCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/GainEffect.cpp"
    click PitchH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/PitchShifterEffect.hpp"
    click PitchCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/PitchShifterEffect.cpp"
    click ReverbH "https://github.com/danilodsp/rt-aep/blob/main/include/effects/ReverbEffect.hpp"
    click ReverbCpp "https://github.com/danilodsp/rt-aep/blob/main/src/effects/ReverbEffect.cpp"
    click GUIH "https://github.com/danilodsp/rt-aep/blob/main/gui/GUIManager.hpp"
    click GUICpp "https://github.com/danilodsp/rt-aep/blob/main/gui/GUIManager.cpp"
    click ImGuiIni "https://github.com/danilodsp/rt-aep/blob/main/imgui.ini"
    click VizH "https://github.com/danilodsp/rt-aep/blob/main/visualization/Visualizer.hpp"
    click VizCpp "https://github.com/danilodsp/rt-aep/blob/main/visualization/Visualizer.cpp"
    click VizReadme "https://github.com/danilodsp/rt-aep/blob/main/visualization/README.md"
```
