# mlecardonnel/drumsheet architecture

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

- Interactive diagram: https://gitdiagram.com/mlecardonnel/drumsheet
- Repository: https://github.com/mlecardonnel/drumsheet

## Overview

DrumSheet is a command-line drum-audio transcription tool. The user supplies audio; the CLI loads four classifiers and delegates transcription to DrumAudio, which detects percussion events, classifies their spectrograms, and produces a LilyPond score before invoking LilyPond to render a PDF. The README also describes the MedleyDB-based training context and the four instrument-specific classifiers. The source excerpts support the runtime flow; model internals and dataset processing are not shown.

Main entry points: [`src/main.py`](https://github.com/mlecardonnel/drumsheet/blob/main/src/main.py) (Transcription CLI), [`src/drum_audio.py`](https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py) (Spectrogram classification), [`models/CY_60epochs`](https://github.com/mlecardonnel/drumsheet/tree/main/models/CY_60epochs) (Cymbal model), [`models/HH_ResNet`](https://github.com/mlecardonnel/drumsheet/tree/main/models/HH_ResNet) (Hi-hat model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Command entry"]
  node_cli["Transcription CLI<br/>[main.py]"]
end

subgraph group_transcription["Audio transcription"]
  node_audio["DrumAudio<br/>[drum_audio.py]"]
  node_detect["Percussion detection<br/>[drum_audio.py]"]
  node_spec["Spectrogram classification<br/>[drum_audio.py]"]
end

subgraph group_classifiers["Instrument classifiers"]
  node_cy["Cymbal model"]
  node_hh["Hi-hat model"]
  node_kd["Kick model"]
  node_sd["Snare model"]
end

subgraph group_score["Score output"]
  node_lygen["LilyPond score generation<br/>[drum_audio.py]"]
  node_lyfile["LilyPond score file"]
  node_pdf["PDF score"]
end

node_user(("Audio provider"))
node_lilypond["LilyPond renderer"]

node_user -->|"provides audio"| node_cli
node_cli -->|"constructs"| node_audio
node_cli -->|"loads model"| node_cy
node_cli -->|"loads model"| node_hh
node_cli -->|"loads model"| node_kd
node_cli -->|"loads model"| node_sd
node_audio -->|"detects events"| node_detect
node_audio -->|"classifies events"| node_spec
node_spec -->|"predicts cymbals"| node_cy
node_spec -->|"predicts hi-hats"| node_hh
node_spec -->|"predicts kicks"| node_kd
node_spec -->|"predicts snares"| node_sd
node_cli -->|"requests score"| node_lygen
node_lygen -->|"writes score"| node_lyfile
node_cli -->|"requests rendering"| node_lilypond
node_lilypond -->|"renders PDF"| node_pdf

click node_cli "https://github.com/mlecardonnel/drumsheet/blob/main/src/main.py"
click node_audio "https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py"
click node_detect "https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py"
click node_spec "https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py"
click node_cy "https://github.com/mlecardonnel/drumsheet/tree/main/models/CY_60epochs"
click node_hh "https://github.com/mlecardonnel/drumsheet/tree/main/models/HH_ResNet"
click node_kd "https://github.com/mlecardonnel/drumsheet/tree/main/models/KD_ResNet"
click node_sd "https://github.com/mlecardonnel/drumsheet/tree/main/models/SD_ResNet"
click node_lygen "https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py"
click node_lyfile "https://github.com/mlecardonnel/drumsheet/blob/main/data/lilypond_files/MusicDelta_80sRock_Drum.ly"
click node_pdf "https://github.com/mlecardonnel/drumsheet/blob/main/data/pdf_files/MusicDelta_80sRock_Drum.pdf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli toneBlue
class node_audio,node_detect,node_spec toneAmber
class node_cy,node_hh,node_kd,node_sd toneMint
class node_lygen,node_lyfile,node_pdf toneRose
class node_user,node_lilypond toneIndigo
```

## Components

### Command entry

- [Transcription CLI](https://github.com/mlecardonnel/drumsheet/blob/main/src/main.py): `src/main.py`

### Audio transcription

- [DrumAudio](https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py): `src/drum_audio.py`
- [Percussion detection](https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py): `src/drum_audio.py`
- [Spectrogram classification](https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py): `src/drum_audio.py`

### Instrument classifiers

- [Cymbal model](https://github.com/mlecardonnel/drumsheet/tree/main/models/CY_60epochs): `models/CY_60epochs`
- [Hi-hat model](https://github.com/mlecardonnel/drumsheet/tree/main/models/HH_ResNet): `models/HH_ResNet`
- [Kick model](https://github.com/mlecardonnel/drumsheet/tree/main/models/KD_ResNet): `models/KD_ResNet`
- [Snare model](https://github.com/mlecardonnel/drumsheet/tree/main/models/SD_ResNet): `models/SD_ResNet`

### Score output

- [LilyPond score generation](https://github.com/mlecardonnel/drumsheet/blob/main/src/drum_audio.py): `src/drum_audio.py`
- [LilyPond score file](https://github.com/mlecardonnel/drumsheet/blob/main/data/lilypond_files/MusicDelta_80sRock_Drum.ly): `data/lilypond_files/MusicDelta_80sRock_Drum.ly`
- [PDF score](https://github.com/mlecardonnel/drumsheet/blob/main/data/pdf_files/MusicDelta_80sRock_Drum.pdf): `data/pdf_files/MusicDelta_80sRock_Drum.pdf`

### Other components

- **Audio provider**
- **LilyPond renderer**

## Connections

- Audio provider → Transcription CLI: provides audio (evidence: `src/main.py`)
- Transcription CLI → DrumAudio: constructs (evidence: `src/main.py`)
- Transcription CLI → Cymbal model: loads model (evidence: `src/main.py`)
- Transcription CLI → Hi-hat model: loads model (evidence: `src/main.py`)
- Transcription CLI → Kick model: loads model (evidence: `src/main.py`)
- Transcription CLI → Snare model: loads model (evidence: `src/main.py`)
- DrumAudio → Percussion detection: detects events (evidence: `src/drum_audio.py`)
- DrumAudio → Spectrogram classification: classifies events (evidence: `src/drum_audio.py`)
- Spectrogram classification → Cymbal model: predicts cymbals (evidence: `src/drum_audio.py`)
- Spectrogram classification → Hi-hat model: predicts hi-hats (evidence: `src/drum_audio.py`)
- Spectrogram classification → Kick model: predicts kicks (evidence: `src/drum_audio.py`)
- Spectrogram classification → Snare model: predicts snares (evidence: `src/drum_audio.py`)
- Transcription CLI → LilyPond score generation: requests score (evidence: `src/main.py`)
- LilyPond score generation → LilyPond score file: writes score (evidence: `src/drum_audio.py`)
- Transcription CLI → LilyPond renderer: requests rendering (evidence: `src/main.py`)
- LilyPond renderer → PDF score: renders PDF
