# rafe34201/subtractive-synthesizer-diy architecture

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

- Interactive diagram: https://gitdiagram.com/rafe34201/subtractive-synthesizer-diy
- Repository: https://github.com/rafe34201/subtractive-synthesizer-diy

## Overview

##### Project type and purpose
- This is a standalone desktop application—a subtractive software synthesizer written entirely in Python.
- It reads live MIDI input, provides a graphical UI for parameter control, generates waveforms, applies filtering and envelopes, and outputs audio in real time without external plugins.

##### File structure
- Top-level:
- README.md — documents features, installation, usage
- synth.py — the single Python entry point containing UI, MIDI handling, DSP, plotting, and audio I/O
- No separate frontend/backend folders; it’s a monolithic script organized into logical classes or functions for each synthesizer stage.
- Dependencies in README: numpy, sounddevice, mido/python-rtmidi, matplotlib, scipy.

##### README for additional insights
- Core functionality:
- Five oscillators (Sin, Square, Saw, Triangle, Noise)
- Four filters (Highpass, Lowpass, Bandpass, Bandreject) with cutoff and slope controls
- ADS envelope (Attack, Decay, Sustain)
- Master volume and pitch fine-tune
- Real-time waveform and ADS curve plotting
- On-screen keyboard display
- Workflow: connect MIDI controller → launch synth.py → confirm device → play/adjust.

##### Detail
- Processing stage explicitly rather than lumping into one block.
- Configuration or setup steps (e.g., “Confirm MIDI Device” before input flow).
- Real-time constraints (e.g., callback buffer size).

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Inputs
    ExternalMIDI["External MIDI Controller"]:::input
    Confirm["Confirm MIDI Device"]:::input
    MIDI["MIDI Input Manager\n(mido, python-rtmidi)"]:::input
    GUI["GUI Layer\n(matplotlib UI)"]:::input

    %% Synth Engine with DSP modules
    subgraph "Synth Engine"
        direction TB
        Osc["Oscillator Module\n(numpy)"]:::dsp
        Fil["Filter Module\n(scipy)"]:::dsp
        Env["Envelope Module"]:::dsp
        Mix["Mixer / Master Control"]:::dsp
    end

    %% Visualization and Audio Output
    Plot["Plotting Subsystem\n(matplotlib)"]:::viz
    AudioOut["Audio Output Manager\n(sounddevice)"]:::dsp

    %% Flows
    ExternalMIDI --> Confirm --> MIDI --> Osc
    GUI --> Mix
    Osc --> Fil --> Env --> Mix
    Mix --> AudioOut
    Mix --> Plot --> GUI

    %% Click Events
    click MIDI "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click GUI "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click Plot "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click Osc "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click Fil "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click Env "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click Mix "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click AudioOut "https://github.com/rafe34201/subtractive-synthesizer-diy/blob/main/synth.py"
    click README["README.md"] "README.md"

    %% Styles
    classDef input fill:#9f6,stroke:#393,stroke-width:1px
    classDef dsp fill:#6cf,stroke:#039,stroke-width:1px
    classDef viz fill:#f90,stroke:#c60,stroke-width:1px
```
