# eitomurakami/raytone architecture

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

- Interactive diagram: https://gitdiagram.com/eitomurakami/raytone
- Repository: https://github.com/eitomurakami/raytone

## Overview

##### Project type and purpose
- RayTone is a standalone Unity application (Assets/, ProjectSettings/, Packages/), not a web/server app.
- It’s a node-based audiovisual sequencer, integrating the ChucK audio language and GLSL shaders into Unity as native plugins.

##### File structure
- Top‐level:
– RayTone/Assets – contains all Unity assets: Scripts (“/Scripts”), Prefabs, Materials, Models, Graphics/Shaders, Plugins, StreamingAssets, Scenes, Settings.
– RayTone/Packages & RayTone/ProjectSettings – manifest and pipeline configuration for the Universal Render Pipeline (URP), audio, input, build targets.
– RayToneShaderRenderer/ – native C++ OpenGL plugin source for accelerated shader rendering.
- Under Assets:
– Assets/Chunity – native bundles per platform and C# wrappers for embedding a ChucK VM.
– Assets/Plugins/RtMidi – C# wrappers for MIDI I/O.
– Assets/Plugins/SimpleFileBrowser – drop-in file-browser UI module.
– Assets/RayTone – core C# node graph:
· Scripts/Controllers – engine glue (NodeGraph manager, event dispatch, singleton access).
· Scripts/Units – class hierarchies for ControlUnits (e.g., Add, Lerp), GraphicsUnits (shader effects) and VoiceUnits.
· Graphics/Shaders & Plugins – GLSL templates and native bundles driving OpenGL calls.
· StreamingAssets – ChucK (.ck) tutorials, templates, user scripts and fragment shader templates.
- Key indicators of architecture:
– “Plugins” directories hold native bridges, showing a plugin-based modular approach.
– “Scripts/Units” and “Scripts/Controllers” map to an MVC‐style separation between model (node data), view (UI/Renderer), and controller (runtime logic).

##### README for additional insight
- Confirms: Node-based, programmable audio (ChucK) and graphics (GLSL).
- Emphasis on “playful” patching—so the core is a live node‐graph runtime engine.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Engine Core
    subgraph "Unity Engine Core"
        UECore["Unity Engine Core"]:::engine
    end

    %% Managed C# Layer
    subgraph "Managed C# Layer"
        NGManager["Node Graph Manager"]:::managed
        UI["UI Layer"]:::managed
        AudioBridge["Chunity Bridge"]:::managed
        GraphicsController["Graphics Controller"]:::managed
        InputIO["Input & I/O"]:::managed
    end

    %% Native Plugins
    subgraph "Native Plugins"
        ChucKVM["ChucK VM Plugin"]:::native
        ShaderPlugin["OpenGL Shader Plugin"]:::native
    end

    %% Assets & Resources
    subgraph "Assets & Resources"
        StreamingChucK["StreamingAssets: ChucK Scripts"]:::assets
        StreamingShaders["StreamingAssets: Shader/Templates"]:::assets
        Tutorials["StreamingAssets: Tutorials"]:::assets
        SrcResources["StreamingAssets: src"]:::assets
        TextMeshProAssets["TextMesh Pro Assets"]:::assets
    end

    %% Relationships
    UECore -->|hosts UI| UI
    UECore -->|hosts Audio| AudioBridge
    UECore -->|hosts Graphics| GraphicsController
    UECore -->|hosts I/O| InputIO

    UI -->|user input| NGManager
    InputIO -->|MIDI events| NGManager
    InputIO -->|file I/O| UI

    NGManager -->|spawn units| AudioBridge
    NGManager -->|spawn units| GraphicsController

    AudioBridge -->|calls VM APIs| ChucKVM
    ChucKVM -->|audio output| UECore

    GraphicsController -->|enqueue draw| ShaderPlugin
    ShaderPlugin -->|render output| UECore

    StreamingChucK -.->|loads script| AudioBridge
    StreamingShaders -.->|loads shader| GraphicsController
    Tutorials -.->|loads templates| UI
    SrcResources -.->|loads templates| AudioBridge
    TextMeshProAssets -.->|UI resources| UI

    %% Click Events
    click UECore "https://github.com/eitomurakami/raytone/blob/main/RayTone/Packages/manifest.json"
    click UECore "https://github.com/eitomurakami/raytone/tree/main/RayTone/ProjectSettings"
    click NGManager "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Scripts/Controllers/"
    click NGManager "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Prefabs/Controllers/"
    click UI "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Scripts/UI/"
    click UI "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/TextMesh Pro/"
    click UI "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/Plugins/SimpleFileBrowser/"
    click AudioBridge "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/Chunity/Scripts/"
    click AudioBridge "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/Chunity/Plugins/"
    click StreamingChucK "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/StreamingAssets/ChucK/"
    click GraphicsController "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Graphics/Scripts/"
    click StreamingShaders "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Graphics/Shaders/"
    click ShaderPlugin "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/RayTone/Graphics/Plugins/"
    click ShaderPlugin "https://github.com/eitomurakami/raytone/tree/main/RayToneShaderRenderer/"
    click InputIO "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/Plugins/RtMidi/"
    click StreamingShaders "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/StreamingAssets/Shaders/"
    click Tutorials "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/StreamingAssets/Tutorials/"
    click SrcResources "https://github.com/eitomurakami/raytone/tree/main/RayTone/Assets/StreamingAssets/src/"

    %% Styles
    classDef engine fill:#D3D3D3,stroke:#333,stroke-width:1px;
    classDef managed fill:#AED6F1,stroke:#333,stroke-width:1px;
    classDef native fill:#ABEBC6,stroke:#333,stroke-width:1px;
    classDef assets fill:#F9E79F,stroke:#333,stroke-width:1px;
```
