# fleshold/soundrecsprobe architecture

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

- Interactive diagram: https://gitdiagram.com/fleshold/soundrecsprobe
- Repository: https://github.com/fleshold/soundrecsprobe

## Overview

##### Main Components

A. Application Layer (Kotlin)
- MainActivity (Entry point)
- RecordPlayScreen (UI Component)
- RecordEngine Kotlin wrapper

B. Native Layer (C++)
- AudioRecordingProbe (Core audio handling)
- RecordEngine (Native implementation)
- JNI Bridge (native-lib.cpp)

C. Android System Audio APIs
- OpenSL ES (API 16+)
- AAudio (API 27+)

- [UI Layer]
- ↕
- [Application Layer]
- ↕
- [Native Layer]
- ↕
- [System Audio APIs]

##### Component Relationships

- UI Layer → Application Layer (User interactions)
- Application Layer → Native Layer (JNI calls)
- Native Layer → System Audio APIs (Audio recording)
- Bidirectional audio data flow between components

##### Specific Elements

a) UI Components:
- [RecordPlayScreen.kt] → [MainActivity.kt]

b) Bridge Layer:
- [RecordEngine.kt] ←→ [JNI Bridge]

c) Native Implementation:
- [AudioRecordingProbe.cpp/h] ←→ [RecordEngine.cpp/h]

d) System API Selection:
- [API Version Check]
- ↙            ↘
- [OpenSL ES]  [AAudio]

##### Technical Details to Highlight

- JNI interface methods
- Audio buffer flow
- API version-dependent paths
- Resource management
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px
    classDef kotlin fill:#98FB98,stroke:#333,stroke-width:2px
    classDef cpp fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef system fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef api fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% UI Layer
    subgraph UI_Layer
        RecordPlayScreen["RecordPlayScreen"]:::ui
        MainActivity["MainActivity"]:::ui
        ActivityLayout["Activity Layout"]:::ui
    end

    %% Application Layer
    subgraph Application_Layer
        RecordEngineKt["RecordEngine Kotlin Wrapper"]:::kotlin
    end

    %% Native Layer
    subgraph Native_Layer
        JNIBridge["JNI Bridge"]:::cpp
        RecordEngine["RecordEngine"]:::cpp
        AudioRecordingProbe["AudioRecordingProbe"]:::cpp
        NativeBuild["Native Build Config"]:::cpp
    end

    %% System APIs
    subgraph System_APIs
        APICheck{"API Version Check"}:::system
        OpenSLES["OpenSL ES\n(API 16+)"]:::api
        AAudio["AAudio\n(API 27+)"]:::api
    end

    %% Relationships
    RecordPlayScreen --> MainActivity
    MainActivity --> RecordEngineKt
    RecordEngineKt <--> JNIBridge
    JNIBridge <--> RecordEngine
    RecordEngine <--> AudioRecordingProbe
    AudioRecordingProbe --> APICheck
    APICheck -->|API < 27| OpenSLES
    APICheck -->|API >= 27| AAudio
    MainActivity --- ActivityLayout

    %% Click Events
    click MainActivity "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/java/ru/ric_kos/soundrecsprobe/MainActivity.kt"
    click RecordPlayScreen "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/java/ru/ric_kos/soundrecsprobe/ui/RecordPlayScreen.kt"
    click RecordEngineKt "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/java/ru/ric_kos/soundrecsprobe/RecordEngine.kt"
    click AudioRecordingProbe "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/cpp/AudioRecordinProbe.cpp"
    click RecordEngine "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/cpp/RecordEngine.cpp"
    click JNIBridge "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/cpp/native-lib.cpp"
    click ActivityLayout "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/res/layout/activity_main.xml"
    click NativeBuild "https://github.com/fleshold/SoundRecsProbe/blob/master/app/src/main/cpp/CMakeLists.txt"

    %% Legend
    subgraph Legend
        UI[UI Components]:::ui
        KotlinComp[Kotlin Components]:::kotlin
        CPPComp[C++ Components]:::cpp
        SystemComp[System Components]:::system
        APIComp[Audio APIs]:::api
    end
```
