# milkdrop2077/milkdrop3 architecture

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

- Interactive diagram: https://gitdiagram.com/milkdrop2077/milkdrop3
- Repository: https://github.com/milkdrop2077/milkdrop3

## Overview

##### Project Type and Purpose
- MilkDrop3 is an audio visualization application that processes any audio source (Spotify, YouTube, Winamp, etc.) and renders dynamic visual presets.
- It supports traditional MilkDrop presets, new double-preset (.milk2) setups, and a rich set of controls such as beat detection, shader effects, and user key shortcuts.
- The project incorporates audio capture/processing, shader scripting via a variant of the EEL language, and a visual rendering engine with a DirectX-based display.

##### Analyzing the File Structure
- The project is organized under the “code” directory. Within it, several key directories indicate major architectural modules:
- audio: Contains source files (e.g., audiobuf.cpp/h, loopback-capture.*) that handle audio input, buffering, logging, and preferences.
- ns-eel2: This holds the C/C++ source for the EEL scripting engine (e.g., ns-eel.h, nseel-compiler.c) used for processing shader code or visual function scripts.
- resources: Holds preset data, shader files (*.fx), supporting MilkDrop2 visual effects assets, and documentation that illustrate resource management.
- vis_milk2: Contains all files related to the visual rendering engine. This includes DirectX context management (dxcontext.cpp/h), shader logic, FFT processing, and plugin integration. Also, user interface files are present (menus, resource manifest, project files) that likely correspond to the MilkPanel and on-screen controls.
- The solution file (MilkDrop3.sln) suggests usage of Visual Studio and a typical C/C++ build environment.

- Core Audio Module:
- Handles audio capture and buffering (code/audio) from varied sources.
- Manages logging and preferences.
- EEL Scripting / Shader Processing Module:
- Implements the core scripting engine (code/ns-eel2) that interprets and compiles preset scripts for visual effects.
- Provides extensibility for custom functions in presets.
- Visual Rendering Engine:
- Built in the vis_milk2 folder; uses DirectX (dxcontext.cpp/h) for rendering visualizations.
- Resource and Preset Manager:
- Uses assets from the resources folder (preset shaders, blend effects, configuration files) to load and display visual presets.
- Manages both classic MilkDrop and enhanced double-preset (.milk2) mechanisms.
- User Interface / Control Module:
- Within vis_milk2, the UI elements, menu handling, key-capturing logic (supporting dozens of shortcuts) and configuration panels (e.g., MilkPanel) are managed.
- Supports external control features for playlist functions and direct preset/sprite manipulation.
- External Service / Player Integration:
- Although not a separate folder, the README details integration with external players (Winamp, Spotify, etc.), which likely align with the audio module and a launcher integrated in the control module.

##### Architectural Patterns and Technologies
- Modular Separation: The clear division between audio processing, shader/script processing, and visual rendering suggests loose coupling and modular design.
- UI and Resource Management: The use of configuration INI files and dedicated directories (e.g., resources) shows a resource-manager pattern.
- DirectX-based Rendering: The vis_milk2 module embeds DirectX usage, which is central for real-time visualizations.
- Scripting/Compiler Subsystem: The ns-eel2 folder implements components of a mini-compiler or interpreter, dealing with dynamic shader presets.
- Dependency Flow: There is a unidirectional dependency starting from audio capture to processing via the EEL engine and finally to visual rendering, with user interaction serving as both an input to control and to modify behavior.

##### Final Inclusions
- Clear labels: Each module/component should have a descriptive title (e.g., “Audio Capture & Processing”, “Shader Scripting Engine”, “DirectX Renderer”, “Preset Resource Manager”, “User Interface & Control”).
- Notation for External Interactions: Indicate integration points with external services (media players) using boundary symbols or connectors.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% System-Level Layer
    subgraph "System-Level"
        F["External Player Integration"]:::external
        A["Audio Capture & Processing"]:::audio
    end

    %% Middleware Layer
    subgraph "Middleware"
        R["Resource & Preset Manager"]:::resources
        S["EEL Scripting & Shader Processing"]:::scripting
    end

    %% Presentation Layer
    subgraph "Presentation"
        UI["User Interface & Control"]:::ui
        V["Visual Rendering Engine (DirectX & FFT)"]:::rendering
    end

    %% Connections
    F -->|"player_commands"| A
    UI -->|"playback_control"| A
    A -->|"audio_data"| V
    UI -->|"control_commands"| V
    UI -->|"preset_selection"| R
    R -->|"preset_scripts"| S
    S -->|"compiled_output"| V

    %% Click Events
    click A "https://github.com/milkdrop2077/milkdrop3/tree/main/code/audio"
    click S "https://github.com/milkdrop2077/milkdrop3/tree/main/code/ns-eel2"
    click V "https://github.com/milkdrop2077/milkdrop3/tree/main/code/vis_milk2"
    click R "https://github.com/milkdrop2077/milkdrop3/tree/main/code/resources"
    click UI "https://github.com/milkdrop2077/milkdrop3/tree/main/code/vis_milk2"

    %% Styles
    classDef external fill:#b3e6ff,stroke:#333,stroke-width:2px;
    classDef audio fill:#a0c4ff,stroke:#333,stroke-width:2px;
    classDef scripting fill:#caffbf,stroke:#333,stroke-width:2px;
    classDef rendering fill:#ffb347,stroke:#333,stroke-width:2px;
    classDef resources fill:#ff6961,stroke:#333,stroke-width:2px;
    classDef ui fill:#fdfd96,stroke:#333,stroke-width:2px;
```
