How dhnguyencs/digital-piano works
Digital-Piano is a desktop piano synthesizer that accepts live MIDI input and plays MIDI files with a visual keyboard. Its main workflow starts in main.cpp, which initializes audio and launches controller threads; the controller handles piano interaction and song playback, while the mapper translates notes into key and sound state. The README also documents playback-speed and seek controls. MIDI parsing and real-time MIDI I/O are distinct supporting capabilities. Source excerpts do not show every controller method, so some documented or strongly implied links are marked unverified.
Main entry points: main.cpp App launcher · MAPPER.h Note mapper · DigitalPiano.h Song playback · MidiFile.cpp MIDI file model
Components 25
Application
- App launcher
main.cpp - Piano controller
DigitalPiano.h - Window settings
GLOBALVARIABLES.h
Piano Interaction
- Piano UI
DigitalPiano.h - Pixel game engine
olcPixelGameEngineGL.h - Key layout
Keys.h - Note mapper
MAPPER.h - Vector math
vectors.h
MIDI Processing
- Live MIDI input
DigitalPiano.h - RtMidi interface
RtMidi.h - RtMidi backend
RtMidi.cpp - Song playback
DigitalPiano.h - MIDI file model
src/MidiFile.cpp - MIDI event lists
src/MidiEventList.cpp - MIDI events
src/MidiEvent.cpp - MIDI messages
src/MidiMessage.cpp - Binasc conversion
src/Binasc.cpp - Option parser
src/Options.cpp - MIDI library
include - Bundled MIDI songs
MIDIFILES
Audio
- SoundFont
soundfile_3.sf2 - SoundFont synthesizer
tsf.h - SDL audio output
minisdl_audio.h
Other components
- MIDI device
- Song selection
Connections 30
- App launcher → Piano controller: launches threads
main.cpp - App launcher → Note mapper: constructs
main.cpp - App launcher → Piano UI: constructs app
main.cpp - App launcher → SoundFont synthesizer: loads SoundFont
main.cpp - App launcher → SDL audio output: opens output
main.cpp - App launcher → Window settings: configures window
main.cpp - Piano controller → Live MIDI input: runs input thread
main.cpp - Piano controller → Song playback: runs playback thread
main.cpp - Piano controller → Piano UI: renders interface
DigitalPiano.h - Piano UI → Pixel game engine: extends engine
DigitalPiano.h - Piano UI → Note mapper: updates key state
DigitalPiano.h - Note mapper → Key layout: builds keyboard
MAPPER.h - Key layout → Vector math: uses geometry
Keys.h - Note mapper → Vector math: uses geometry
MAPPER.h - MIDI device → Live MIDI input: sends notes
- Live MIDI input → RtMidi interface: polls input
DigitalPiano.h - RtMidi backend → RtMidi interface: implements API
RtMidi.cpp - Song selection → Song playback: selects song
README.md - Song playback → MIDI file model: reads MIDI
README.md - Bundled MIDI songs → Song playback: provides songs
README.md - MIDI file model → MIDI library: uses declarations
include/MidiFile.h - MIDI library → MIDI event lists: stores tracks
include/MidiFile.h - MIDI event lists → MIDI events: contains events
- MIDI events → MIDI messages: uses message
- MIDI file model → Binasc conversion: supports conversion
src/MidiFile.cpp - MIDI file model → Option parser: uses options
- Song playback → Note mapper: maps played notes
DigitalPiano.h - Note mapper → SoundFont synthesizer: triggers notes
MAPPER.h - App launcher → SoundFont synthesizer: renders samples
main.cpp - SoundFont → SoundFont synthesizer: supplies presets