# duskozi/nmidieditor architecture

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

- Interactive diagram: https://gitdiagram.com/duskozi/nmidieditor
- Repository: https://github.com/duskozi/nmidieditor

## Overview

nMIDI Editor is a Windows MIDI editor and player. The main workflow is to open or create a song, edit notes and song data in the piano roll and related lanes, then save the MIDI file; the main window also coordinates playback and track output. Distinct branches include track lanes, note processing, and suggested piano fingering. Edges are limited to README-documented behavior and relationships visible in the supplied source index or excerpts; several feature implementations were not sampled.

Main entry points: [`MainWindow.xaml.cs`](https://github.com/duskozi/nmidieditor/blob/main/MainWindow.xaml.cs) (Main window), [`Model/Song.cs`](https://github.com/duskozi/nmidieditor/blob/main/Model/Song.cs) (Song and MIDI files), [`Controls/nMIDI.Controls/Controls/PianoRoll.cs`](https://github.com/duskozi/nmidieditor/blob/main/Controls/nMIDI.Controls/Controls/PianoRoll.cs) (Piano roll control), [`PianoRoll/RollEditor.cs`](https://github.com/duskozi/nmidieditor/blob/main/PianoRoll/RollEditor.cs) (Piano roll editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editing["Editing UI"]
  node_main["Main window<br/>[MainWindow.xaml.cs]"]
  node_roll["Piano roll editor<br/>[RollEditor.cs]"]
  node_lanes["Track lanes<br/>[LaneParts.cs]"]
  node_trackswindow["Lanes window"]
  node_controllers["Controller lanes<br/>[ControllerLane.cs]"]
end

subgraph group_song["Song and theory"]
  node_processing["Note processing<br/>[NoteProcessing.cs]"]
  node_noteops["Note operations<br/>[NoteOps.cs]"]
  node_history["Edit history<br/>[EditHistory.cs]"]
  node_songmodel[("Song and MIDI files<br/>[Song.cs]")]
  node_songops["Song operations<br/>[SongOps.cs]"]
  node_trackvm["Track settings<br/>[TrackViewModel.cs]"]
  node_fingering["Suggested fingering<br/>[Fingering.cs]"]
  node_theory["Note names<br/>[NoteHelper.cs]"]
end

subgraph group_playback["MIDI playback"]
  node_player["MIDI player<br/>[MidiPlayer.cs]"]
  node_outputs["MIDI outputs<br/>[MidiOutputs.cs]"]
  node_input["MIDI input<br/>[MidiInput.cs]"]
end

subgraph group_presentation["Controls and themes"]
  node_rollcontrol["Piano roll control<br/>[PianoRoll.cs]"]
  node_themes["Theme manager<br/>[ThemeManager.cs]"]
end

node_user(("Musician"))
node_midiports{{"MIDI devices"}}

node_user -->|"opens or creates"| node_main
node_main -->|"loads and saves"| node_songmodel
node_main -->|"coordinates edits"| node_roll
node_roll -->|"edits notes"| node_rollcontrol
node_main -->|"applies edits"| node_noteops
node_main -->|"tracks undo"| node_history
node_main -->|"runs commands"| node_processing
node_main -->|"edits song"| node_songops
node_main -->|"configures tracks"| node_trackvm
node_main -->|"shows lanes"| node_lanes
node_user -->|"opens lanes"| node_trackswindow
node_main -->|"edits lane data"| node_controllers
node_songmodel -->|"computes fingering"| node_fingering
node_main -->|"displays suggestions"| node_fingering
node_main -->|"controls playback"| node_player
node_player -->|"reads playback data"| node_songmodel
node_main -->|"selects output"| node_outputs
node_outputs -.->|"opens devices"| node_midiports
node_user -.->|"records MIDI"| node_input
node_main -->|"applies preferences"| node_themes
node_themes -->|"reloads styling"| node_rollcontrol
node_rollcontrol -.->|"formats pitches"| node_theory

click node_main "https://github.com/duskozi/nmidieditor/blob/main/MainWindow.xaml.cs"
click node_roll "https://github.com/duskozi/nmidieditor/blob/main/PianoRoll/RollEditor.cs"
click node_rollcontrol "https://github.com/duskozi/nmidieditor/blob/main/Controls/nMIDI.Controls/Controls/PianoRoll.cs"
click node_lanes "https://github.com/duskozi/nmidieditor/blob/main/Lanes/LaneParts.cs"
click node_trackswindow "https://github.com/duskozi/nmidieditor/blob/main/TracksWindow.xaml.cs"
click node_controllers "https://github.com/duskozi/nmidieditor/blob/main/PianoRoll/ControllerLane.cs"
click node_processing "https://github.com/duskozi/nmidieditor/blob/main/Model/NoteProcessing.cs"
click node_noteops "https://github.com/duskozi/nmidieditor/blob/main/Model/NoteOps.cs"
click node_history "https://github.com/duskozi/nmidieditor/blob/main/Model/EditHistory.cs"
click node_songmodel "https://github.com/duskozi/nmidieditor/blob/main/Model/Song.cs"
click node_songops "https://github.com/duskozi/nmidieditor/blob/main/Model/SongOps.cs"
click node_trackvm "https://github.com/duskozi/nmidieditor/blob/main/Model/TrackViewModel.cs"
click node_fingering "https://github.com/duskozi/nmidieditor/blob/main/Model/Fingering.cs"
click node_theory "https://github.com/duskozi/nmidieditor/blob/main/Theory/NoteHelper.cs"
click node_player "https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiPlayer.cs"
click node_outputs "https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiOutputs.cs"
click node_input "https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiInput.cs"
click node_themes "https://github.com/duskozi/nmidieditor/blob/main/Themes/ThemeManager.cs"

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_main,node_roll,node_lanes,node_trackswindow,node_controllers toneBlue
class node_processing,node_noteops,node_history,node_songmodel,node_songops,node_trackvm,node_fingering,node_theory toneAmber
class node_player,node_outputs,node_input toneMint
class node_rollcontrol,node_themes toneRose
class node_user,node_midiports toneIndigo
```

## Components

### Editing UI

- [Main window](https://github.com/duskozi/nmidieditor/blob/main/MainWindow.xaml.cs): `MainWindow.xaml.cs`
- [Piano roll editor](https://github.com/duskozi/nmidieditor/blob/main/PianoRoll/RollEditor.cs): `PianoRoll/RollEditor.cs`
- [Track lanes](https://github.com/duskozi/nmidieditor/blob/main/Lanes/LaneParts.cs): `Lanes/LaneParts.cs`
- [Lanes window](https://github.com/duskozi/nmidieditor/blob/main/TracksWindow.xaml.cs): `TracksWindow.xaml.cs`
- [Controller lanes](https://github.com/duskozi/nmidieditor/blob/main/PianoRoll/ControllerLane.cs): `PianoRoll/ControllerLane.cs`

### Song and theory

- [Note processing](https://github.com/duskozi/nmidieditor/blob/main/Model/NoteProcessing.cs): `Model/NoteProcessing.cs`
- [Note operations](https://github.com/duskozi/nmidieditor/blob/main/Model/NoteOps.cs): `Model/NoteOps.cs`
- [Edit history](https://github.com/duskozi/nmidieditor/blob/main/Model/EditHistory.cs): `Model/EditHistory.cs`
- [Song and MIDI files](https://github.com/duskozi/nmidieditor/blob/main/Model/Song.cs): `Model/Song.cs`
- [Song operations](https://github.com/duskozi/nmidieditor/blob/main/Model/SongOps.cs): `Model/SongOps.cs`
- [Track settings](https://github.com/duskozi/nmidieditor/blob/main/Model/TrackViewModel.cs): `Model/TrackViewModel.cs`
- [Suggested fingering](https://github.com/duskozi/nmidieditor/blob/main/Model/Fingering.cs): `Model/Fingering.cs`
- [Note names](https://github.com/duskozi/nmidieditor/blob/main/Theory/NoteHelper.cs): `Theory/NoteHelper.cs`

### MIDI playback

- [MIDI player](https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiPlayer.cs): `Playback/MidiPlayer.cs`
- [MIDI outputs](https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiOutputs.cs): `Playback/MidiOutputs.cs`
- [MIDI input](https://github.com/duskozi/nmidieditor/blob/main/Playback/MidiInput.cs): `Playback/MidiInput.cs`

### Controls and themes

- [Piano roll control](https://github.com/duskozi/nmidieditor/blob/main/Controls/nMIDI.Controls/Controls/PianoRoll.cs): `Controls/nMIDI.Controls/Controls/PianoRoll.cs`
- [Theme manager](https://github.com/duskozi/nmidieditor/blob/main/Themes/ThemeManager.cs): `Themes/ThemeManager.cs`

### Other components

- **Musician**
- **MIDI devices**

## Connections

- Musician → Main window: opens or creates
- Main window → Song and MIDI files: loads and saves (evidence: `MainWindow.xaml.cs`)
- Main window → Piano roll editor: coordinates edits
- Piano roll editor → Piano roll control: edits notes (evidence: `PianoRoll/RollEditor.cs`)
- Main window → Note operations: applies edits
- Main window → Edit history: tracks undo
- Main window → Note processing: runs commands
- Main window → Song operations: edits song
- Main window → Track settings: configures tracks (evidence: `MainWindow.xaml.cs`)
- Main window → Track lanes: shows lanes (evidence: `Lanes/LaneParts.cs`)
- Musician → Lanes window: opens lanes
- Main window → Controller lanes: edits lane data
- Song and MIDI files → Suggested fingering: computes fingering (evidence: `Model/Song.cs`)
- Main window → Suggested fingering: displays suggestions (evidence: `MainWindow.xaml.cs`)
- Main window → MIDI player: controls playback (evidence: `MainWindow.xaml.cs`)
- MIDI player → Song and MIDI files: reads playback data (evidence: `Playback/MidiPlayer.cs`)
- Main window → MIDI outputs: selects output (evidence: `MainWindow.xaml.cs`)
- MIDI outputs → MIDI devices: opens devices
- Musician → MIDI input: records MIDI
- Main window → Theme manager: applies preferences (evidence: `MainWindow.xaml.cs`)
- Theme manager → Piano roll control: reloads styling (evidence: `Themes/ThemeManager.cs`)
- Piano roll control → Note names: formats pitches
