# goatchurchprime/two-voip-godot-4 architecture

> Architecture diagram of the GitHub repository goatchurchprime/two-voip-godot-4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/goatchurchprime/two-voip-godot-4
- Repository: https://github.com/goatchurchprime/two-voip-godot-4

## Overview

##### Main Components

a) Core Components:
- GodotEngine Integration Layer
- Audio Processing Pipeline
- Compression System (Opus)
- Optional Components:
- Noise Suppression (RNNoise)
- Lip Sync System (OVRLipSync)

b) Audio Processing Components:
- Microphone Input Handler
- Audio Effect System
- Audio Stream System
- Resampling System

**[Godot Engine] <---> [GDExtension Interface] <---> [TwoVoip Core]**

**[Microphone Input] --> [AudioEffectOpusChunked] --> [Resampler] --> [Opus Encoder]**

- > [RNNoise] (optional)

- > [OVRLipSync] (optional)

**[Opus Encoded Data] --> [Network Transport (MQTT)] --> [AudioStreamOpusChunked] --> [Audio Output]**

##### Important Elements to Highlight

a) Data Flow:
- Audio sample flow from microphone to output
- Sample rate conversion points
- Compression/decompression stages
- Optional processing branches (noise suppression, lip sync)

- AudioEffectOpusChunked (Rectangle)
- AudioStreamOpusChunked (Rectangle)
- OpusEncoder/Decoder (Hexagon)
- RNNoise Processor (Diamond)
- OVRLipSync Processor (Diamond)

##### Technical Details

Annotations for:
- Sample rates (44.1kHz, 48kHz)
- Frame sizes (960 samples)
- Compression ratios
- Buffer sizes
- Platform-specific variations

##### Implementation Notes

A side panel showing:
- Supported platforms
- Required dependencies
- Build configuration options
- Key initialization parameters

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Integration Layer"
        GE[Godot Engine]
        GDI["GDExtension Interface"]
        TVC[TwoVoip Core]
    end

    subgraph "Audio Processing Pipeline"
        MI[Microphone Input]
        AEO["Audio Effect System"]
        RS["Resampling System"]
        OE[Opus Encoder]
        RNN["Noise Suppression (RNNoise)"]
        OVR["Lip Sync (OVRLipSync)"]
    end

    subgraph "Network & Playback Layer"
        OED[Opus Encoded Data]
        MQTT["Network Transport (MQTT)"]
        ASO["Audio Stream System"]
        AO[Audio Output]
    end

    %% Integration Layer Connections
    GE <--> GDI
    GDI <--> TVC

    %% Audio Processing Pipeline Connections
    MI --> AEO
    AEO --> RS
    RS --> OE
    RS --> RNN
    RS --> OVR
    RNN --> OE
    OVR --> OE

    %% Network & Playback Connections
    OE --> OED
    OED --> MQTT
    MQTT --> ASO
    ASO --> AO

    %% Styling
    classDef core fill:#a8d1f0
    classDef optional fill:#90EE90
    classDef network fill:#FFB347
    classDef integration fill:#DDA0DD

    class GE,GDI,TVC integration
    class MI,AEO,RS,OE,ASO,AO core
    class RNN,OVR optional
    class OED,MQTT network

    %% Click Events
    click GDI "https://github.com/goatchurchprime/two-voip-godot-4/blob/main/addons/twovoip/twovoip.gdextension"
    click AEO "https://github.com/goatchurchprime/two-voip-godot-4/blob/main/src/audio_effect_opus_chunked.cpp"
    click ASO "https://github.com/goatchurchprime/two-voip-godot-4/blob/main/src/audio_stream_opus_chunked.cpp"
    click RS "https://github.com/goatchurchprime/two-voip-godot-4/tree/main/src/speex_resampler/"
    click OVR "https://github.com/goatchurchprime/two-voip-godot-4/blob/main/src/OVRLipSync_Stub.h"
    click RNN "https://github.com/goatchurchprime/two-voip-godot-4/blob/main/src/rnnoise_stub.h"
    click MQTT "https://github.com/goatchurchprime/two-voip-godot-4/tree/main/example/addons/mqtt/"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Optional Components]:::optional
        L3[Network Components]:::network
        L4[Integration Components]:::integration
    end
```
