# nhatle1909/wpf_digital-piano architecture

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

- Interactive diagram: https://gitdiagram.com/nhatle1909/wpf_digital-piano
- Repository: https://github.com/nhatle1909/wpf_digital-piano

## Overview

WPF_Digital-Piano is a Windows desktop instrument: a user triggers notes through the on-screen keyboard or computer keys, which map to frequencies and play synthesized audio. The application also has settings and MIDI-song playback/viewing components. The main window and several view-model relationships are visible in the source index, but unsampled implementations limit confidence about some wiring; those links are marked unverified rather than asserted as calls.

Main entry points: [`WPF_Piano/ViewModel/PianoButtonVM.cs`](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/PianoButtonVM.cs) (Piano keyboard), [`WPF_Piano/ViewModel/SongPlayerVM.cs`](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/SongPlayerVM.cs) (Song transport), [`WPF_Piano/MainWindow.xaml.cs`](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/MainWindow.xaml.cs) (Main window), [`WPF_Piano/ViewModel/MainViewVM.cs`](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/MainViewVM.cs) (Main view model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_main["Main window<br/>[MainWindow.xaml.cs]"]
  node_settingswindow["Settings window"]
  node_mainvm["Main view model<br/>[MainViewVM.cs]"]
  node_scroll["Scroll behavior"]
  node_command["Command adapter<br/>[RelayCommand.cs]"]
end

subgraph group_instrument["Piano instrument"]
  node_keyboard["Piano keyboard<br/>[PianoButtonVM.cs]"]
  node_button["Piano button model<br/>[PianoButton.cs]"]
  node_notevalues["Note frequencies<br/>[NoteValue.cs]"]
  node_keymap["Key mapping<br/>[OemStringMapper.cs]"]
  node_buttoncontrol["Custom key control"]
  node_sound["Sound synthesis<br/>[PianoPlaySound.cs]"]
end

subgraph group_music["Song playback"]
  node_songvm["Song selection<br/>[SongVM.cs]"]
  node_player["Song transport<br/>[SongPlayerVM.cs]"]
  node_songmodel["Song model<br/>[Song.cs]"]
  node_transportmodel["Transport state<br/>[SongPlayer.cs]"]
  node_midiview["MIDI note view<br/>[NoteControl.cs]"]
end

subgraph group_settings["Configuration"]
  node_settingsvm["Settings view model<br/>[PianoSettingsVM.cs]"]
  node_settings["Piano settings<br/>[PianoSettings.cs]"]
  node_settingsmodel["Settings models<br/>[Settings.cs]"]
  node_config["JSON configuration<br/>[appsettings.json]"]
end

node_user(("Player"))
node_audio["Windows audio output"]

node_user -.->|"uses"| node_main
node_main -.->|"connects"| node_mainvm
node_main -.->|"connects"| node_player
node_main -.->|"connects"| node_keyboard
node_main -.->|"configures"| node_scroll
node_mainvm -.->|"references"| node_keyboard
node_mainvm -.->|"references"| node_player
node_mainvm -.->|"references"| node_songvm
node_keyboard -->|"creates"| node_button
node_keyboard -->|"gets frequencies"| node_notevalues
node_keyboard -->|"converts keys"| node_keymap
node_keyboard -->|"renders"| node_buttoncontrol
node_keyboard -->|"plays notes"| node_sound
node_sound -->|"reads synthesis"| node_settings
node_sound -->|"streams audio"| node_audio
node_settingswindow -.->|"connects"| node_settingsvm
node_settingsvm -->|"updates"| node_settings
node_settings -->|"uses models"| node_settingsmodel
node_settings -->|"loads settings"| node_config
node_player -->|"updates state"| node_transportmodel
node_player -->|"creates commands"| node_command
node_player -->|"calculates duration"| node_sound
node_songvm -.->|"uses model"| node_songmodel
node_player -.->|"displays MIDI"| node_midiview

click node_main "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/MainWindow.xaml.cs"
click node_settingswindow "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/SettingsWindow.xaml.cs"
click node_mainvm "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/MainViewVM.cs"
click node_scroll "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Behavior/ScrollViewerBehavior.cs"
click node_keyboard "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/PianoButtonVM.cs"
click node_button "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/PianoButton.cs"
click node_notevalues "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/StaticValue/NoteValue.cs"
click node_keymap "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/OemStringMapper.cs"
click node_buttoncontrol "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/CustomPianoButton.cs"
click node_sound "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/PianoPlaySound.cs"
click node_songvm "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/SongVM.cs"
click node_player "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/SongPlayerVM.cs"
click node_songmodel "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/Song.cs"
click node_transportmodel "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/SongPlayer.cs"
click node_midiview "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/NoteControl.cs"
click node_settingsvm "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/PianoSettingsVM.cs"
click node_settings "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/PianoSettings.cs"
click node_settingsmodel "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/Settings.cs"
click node_config "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/appsettings.json"
click node_command "https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/RelayCommand.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_settingswindow,node_mainvm,node_scroll,node_command toneBlue
class node_keyboard,node_button,node_notevalues,node_keymap,node_buttoncontrol,node_sound toneAmber
class node_songvm,node_player,node_songmodel,node_transportmodel,node_midiview toneMint
class node_settingsvm,node_settings,node_settingsmodel,node_config toneRose
class node_user,node_audio toneIndigo
```

## Components

### Desktop interface

- [Main window](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/MainWindow.xaml.cs): `WPF_Piano/MainWindow.xaml.cs`
- [Settings window](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/SettingsWindow.xaml.cs): `WPF_Piano/SettingsWindow.xaml.cs`
- [Main view model](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/MainViewVM.cs): `WPF_Piano/ViewModel/MainViewVM.cs`
- [Scroll behavior](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Behavior/ScrollViewerBehavior.cs): `WPF_Piano/Behavior/ScrollViewerBehavior.cs`
- [Command adapter](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/RelayCommand.cs): `WPF_Piano/ViewModel/RelayCommand.cs`

### Piano instrument

- [Piano keyboard](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/PianoButtonVM.cs): `WPF_Piano/ViewModel/PianoButtonVM.cs`
- [Piano button model](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/PianoButton.cs): `WPF_Piano/Model/PianoButton.cs`
- [Note frequencies](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/StaticValue/NoteValue.cs): `WPF_Piano/StaticValue/NoteValue.cs`
- [Key mapping](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/OemStringMapper.cs): `WPF_Piano/Helper/OemStringMapper.cs`
- [Custom key control](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/CustomPianoButton.cs): `WPF_Piano/CustomPianoButton.cs`
- [Sound synthesis](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/PianoPlaySound.cs): `WPF_Piano/Helper/PianoPlaySound.cs`

### Song playback

- [Song selection](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/SongVM.cs): `WPF_Piano/ViewModel/SongVM.cs`
- [Song transport](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/SongPlayerVM.cs): `WPF_Piano/ViewModel/SongPlayerVM.cs`
- [Song model](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/Song.cs): `WPF_Piano/Model/Song.cs`
- [Transport state](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/SongPlayer.cs): `WPF_Piano/Model/SongPlayer.cs`
- [MIDI note view](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/NoteControl.cs): `WPF_Piano/NoteControl.cs`

### Configuration

- [Settings view model](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/ViewModel/PianoSettingsVM.cs): `WPF_Piano/ViewModel/PianoSettingsVM.cs`
- [Piano settings](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Helper/PianoSettings.cs): `WPF_Piano/Helper/PianoSettings.cs`
- [Settings models](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/Model/Settings.cs): `WPF_Piano/Model/Settings.cs`
- [JSON configuration](https://github.com/nhatle1909/wpf_digital-piano/blob/main/WPF_Piano/appsettings.json): `WPF_Piano/appsettings.json`

### Other components

- **Player**
- **Windows audio output**

## Connections

- Player → Main window: uses
- Main window → Main view model: connects (evidence: `WPF_Piano/MainWindow.xaml.cs`)
- Main window → Song transport: connects (evidence: `WPF_Piano/MainWindow.xaml.cs`)
- Main window → Piano keyboard: connects (evidence: `WPF_Piano/MainWindow.xaml.cs`)
- Main window → Scroll behavior: configures (evidence: `WPF_Piano/MainWindow.xaml.cs`)
- Main view model → Piano keyboard: references (evidence: `WPF_Piano/ViewModel/MainViewVM.cs`)
- Main view model → Song transport: references (evidence: `WPF_Piano/ViewModel/MainViewVM.cs`)
- Main view model → Song selection: references (evidence: `WPF_Piano/ViewModel/MainViewVM.cs`)
- Piano keyboard → Piano button model: creates (evidence: `WPF_Piano/ViewModel/PianoButtonVM.cs`)
- Piano keyboard → Note frequencies: gets frequencies (evidence: `WPF_Piano/ViewModel/PianoButtonVM.cs`)
- Piano keyboard → Key mapping: converts keys (evidence: `WPF_Piano/ViewModel/PianoButtonVM.cs`)
- Piano keyboard → Custom key control: renders (evidence: `WPF_Piano/ViewModel/PianoButtonVM.cs`)
- Piano keyboard → Sound synthesis: plays notes (evidence: `WPF_Piano/ViewModel/PianoButtonVM.cs`)
- Sound synthesis → Piano settings: reads synthesis (evidence: `WPF_Piano/Helper/PianoPlaySound.cs`)
- Sound synthesis → Windows audio output: streams audio (evidence: `WPF_Piano/Helper/PianoPlaySound.cs`)
- Settings window → Settings view model: connects
- Settings view model → Piano settings: updates (evidence: `WPF_Piano/ViewModel/PianoSettingsVM.cs`)
- Piano settings → Settings models: uses models (evidence: `WPF_Piano/Helper/PianoSettings.cs`)
- Piano settings → JSON configuration: loads settings (evidence: `WPF_Piano/Helper/PianoSettings.cs`)
- Song transport → Transport state: updates state (evidence: `WPF_Piano/ViewModel/SongPlayerVM.cs`)
- Song transport → Command adapter: creates commands (evidence: `WPF_Piano/ViewModel/SongPlayerVM.cs`)
- Song transport → Sound synthesis: calculates duration (evidence: `WPF_Piano/ViewModel/SongPlayerVM.cs`)
- Song selection → Song model: uses model (evidence: `WPF_Piano/ViewModel/SongVM.cs`)
- Song transport → MIDI note view: displays MIDI
