# szechyjs/dsd architecture

> Architecture diagram of the GitHub repository szechyjs/dsd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/szechyjs/dsd
- Repository: https://github.com/szechyjs/dsd

## Overview

##### Main Components Identification
The system should be divided into these primary components:

a. Input Processing Layer
- Audio Input Handler (discriminator tap audio)
- File Input Handler
- Serial Input Handler

b. Signal Processing Core
- Frame Synchronization
- Symbol Detection
- Dibit Processing
- Upsampling

c. Protocol Decoders
- DMR (Digital Mobile Radio)
- DSTAR
- NXDN
- P25 Phase 1
- ProVoice
- X2-TDMA

d. Error Correction Components
- Golay24
- Hamming
- Reed-Solomon

e. Audio Output
- MBE Processing (via mbelib)
- Audio Synthesis
- PortAudio Interface

##### Specific Component Details

Input Section:
**[Audio Input] ─┐**
**[File Input]  ─┼─→ [Frame Sync] → [Symbol Detection]**
**[Serial Input]─┘**

Core Processing:
**[Symbol Detection] → [Dibit Processing] → [Protocol Detection]**

Protocol Decoders (parallel):
- ┌─→ [DMR Decoder]
- → [DSTAR Decoder]
**[Protocol Router]─┼─→ [NXDN Decoder]**
- → [P25P1 Decoder]
- → [ProVoice Decoder]

##### Technical Details to Highlight

- Frame synchronization mechanisms
- MBE processing integration
- Error correction application points
- Audio synthesis pipeline

## Diagram (Mermaid)

```mermaid
graph TB
    %% Input Layer
    subgraph Input
        AudioIn[Audio Input]
        FileIn[File Input]
        SerialIn[Serial Input]
    end

    %% Signal Processing Core
    subgraph Processing
        FrameSync[Frame Synchronization]
        SymbolDet[Symbol Detection]
        DibitProc[Dibit Processing]
        Upsample[Upsampling]
    end

    %% Protocol Decoders
    subgraph Protocols
        direction TB
        ProtRouter{Protocol Router}
        DMR[DMR Decoder]
        DSTAR[DSTAR Decoder]
        NXDN[NXDN Decoder]
        P25P1[P25 Phase 1 Decoder]
        ProVoice[ProVoice Decoder]
        X2TDMA[X2-TDMA Decoder]
    end

    %% Error Correction
    subgraph ErrorCorrection
        Golay[Golay24]
        Hamming[Hamming]
        ReedSolomon[Reed-Solomon]
    end

    %% Audio Output
    subgraph Output
        MBEProc[MBE Processing]
        AudioSynth[Audio Synthesis]
        PortAudio[PortAudio Interface]
    end

    %% Connections
    AudioIn --> FrameSync
    FileIn --> FrameSync
    SerialIn --> FrameSync
    FrameSync --> SymbolDet
    SymbolDet --> DibitProc
    DibitProc --> Upsample
    Upsample --> ProtRouter

    ProtRouter --> DMR
    ProtRouter --> DSTAR
    ProtRouter --> NXDN
    ProtRouter --> P25P1
    ProtRouter --> ProVoice
    ProtRouter --> X2TDMA

    DMR & DSTAR & NXDN & P25P1 & ProVoice & X2TDMA --> MBEProc
    
    ErrorCorrection -.-> DMR
    ErrorCorrection -.-> DSTAR
    ErrorCorrection -.-> NXDN
    ErrorCorrection -.-> P25P1

    MBEProc --> AudioSynth
    AudioSynth --> PortAudio

    %% Styles
    classDef input fill:#a8d5ff
    classDef processing fill:#98fb98
    classDef protocol fill:#f0e68c
    classDef error fill:#ffa07a
    classDef output fill:#ff9999

    class AudioIn,FileIn,SerialIn input
    class FrameSync,SymbolDet,DibitProc,Upsample processing
    class DMR,DSTAR,NXDN,P25P1,ProVoice,X2TDMA protocol
    class Golay,Hamming,ReedSolomon error
    class MBEProc,AudioSynth,PortAudio output

    %% Click Events
    click AudioIn "https://github.com/szechyjs/dsd/blob/master/src/dsd_audio.c"
    click FileIn "https://github.com/szechyjs/dsd/blob/master/src/dsd_file.c"
    click SerialIn "https://github.com/szechyjs/dsd/blob/master/src/dsd_serial.c"
    click FrameSync "https://github.com/szechyjs/dsd/blob/master/src/dsd_frame_sync.c"
    click SymbolDet "https://github.com/szechyjs/dsd/blob/master/src/dsd_symbol.c"
    click DibitProc "https://github.com/szechyjs/dsd/blob/master/src/dsd_dibit.c"
    click Upsample "https://github.com/szechyjs/dsd/blob/master/src/dsd_upsample.c"
    click DMR "https://github.com/szechyjs/dsd/blob/master/src/dmr_voice.c"
    click DSTAR "https://github.com/szechyjs/dsd/blob/master/src/dstar.c"
    click NXDN "https://github.com/szechyjs/dsd/blob/master/src/nxdn96.c"
    click P25P1 "https://github.com/szechyjs/dsd/blob/master/src/p25p1_ldu.c"
    click ProVoice "https://github.com/szechyjs/dsd/blob/master/src/provoice.c"
    click X2TDMA "https://github.com/szechyjs/dsd/blob/master/src/x2tdma_voice.c"
    click Golay "https://github.com/szechyjs/dsd/blob/master/include/Golay24.hpp"
    click Hamming "https://github.com/szechyjs/dsd/blob/master/include/Hamming.hpp"
    click ReedSolomon "https://github.com/szechyjs/dsd/blob/master/include/ReedSolomon.hpp"
    click MBEProc "https://github.com/szechyjs/dsd/blob/master/src/dsd_mbe.c"
    click PortAudio "https://github.com/szechyjs/dsd/blob/master/src/pa_devs.c"
```
