# mayfer/string_pluck architecture

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

- Interactive diagram: https://gitdiagram.com/mayfer/string_pluck
- Repository: https://github.com/mayfer/string_pluck

## Overview

##### Main Components
- User Interface (UI) Layer:
- index.html (and other HTML files in subfolders such as wavecomputer) provide the visual front end.
- Audio Engine / Processing Layer:
- Scripts like audio_shader.js, plucker.js, tonejs_midi.js, and various legacy worklet files (under the “legacy” and “legacy/worklet” folders) suggest that this layer handles sound synthesis, audio processing (using web audio worklets and shaders), and MIDI playback.
- MIDI and Sound Resource Management:
- The “midis” folder is a key repository containing MIDI files from various composers and genres. This resource likely enables the simulation to load and interact with pre-defined musical pieces.
- Legacy / Experimental Modules:
- The “legacy” folder contains several older or alternate implementations (like chopin.js, oscillator modules, and various experimental worklets) that may still influence current behavior or are available for fallback purposes.
- The “AppIcons” folder (with its both iOS and Android structures) shows that the project is tailored to be deployed as a mobile web or hybrid application.

##### Out Relationships and Interactions
- The Audio Engine works with Web Audio API components such as Audio Worklets—with files in “legacy/worklet” and audio_shader.js—to generate sound, possibly visualizing audio waveforms in sync with the UI.
- MIDI files provided in the “midis” repository are loaded (likely via tonejs_midi.js or similar modules) into the audio engine for synthesis or playback.
- Third-party libraries such as preact (via preact.htm.module.js) and tonejs libraries should be included to indicate integration points.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface (UI) Layer"
        UI1["index.html"] 
        UI2["WaveComputer Files"]
    end

    %% Audio Engine / Processing Layer
    subgraph "Audio Engine / Processing Layer"
        AE1["audio_shader.js"]
        AE2["plucker.js"]
        AE3["tonejs_midi.js"]
        AE4["Legacy Worklet Files"]
    end

    %% MIDI and Sound Resource Manager
    subgraph "MIDI & Sound Resource Manager"
        MIDI["MIDI Files (midis folder)"]
    end

    %% Legacy / Experimental Modules
    subgraph "Legacy / Experimental Modules"
        LEGACY["Legacy Modules (legacy folder)"]
    end

    %% Assets & Cross-Platform Icons
    subgraph "Asset Management"
        ASSET["AppIcons"]
    end

    %% Connections
    UI1 -->|"triggers"| AE1
    UI1 -->|"triggers"| AE2
    UI2 -->|"updates"| UI1
    AE3 -->|"loads"| MIDI
    LEGACY -->|"fallback"| AE1
    AE4 -->|"integrates"| AE1
    UI1 -->|"loads"| ASSET
    UI2 -->|"interacts"| AE1

    %% Click Events
    click UI1 "https://github.com/mayfer/string_pluck/blob/master/index.html"
    click UI2 "https://github.com/mayfer/string_pluck/tree/master/wavecomputer"
    click AE1 "https://github.com/mayfer/string_pluck/blob/master/audio_shader.js"
    click AE2 "https://github.com/mayfer/string_pluck/blob/master/plucker.js"
    click AE3 "https://github.com/mayfer/string_pluck/blob/master/tonejs_midi.js"
    click AE4 "https://github.com/mayfer/string_pluck/tree/master/legacy/worklet"
    click MIDI "https://github.com/mayfer/string_pluck/tree/master/midis"
    click LEGACY "https://github.com/mayfer/string_pluck/tree/master/legacy"
    click ASSET "https://github.com/mayfer/string_pluck/tree/master/AppIcons"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef audio fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef midi fill:#a9dfbf,stroke:#239b56,stroke-width:2px;
    classDef legacy fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef asset fill:#f9e79f,stroke:#b9770e,stroke-width:2px;

    class UI1,UI2 ui;
    class AE1,AE2,AE3,AE4 audio;
    class MIDI midi;
    class LEGACY legacy;
    class ASSET asset;
```
