Architecture¶
High-Level Design¶
The project is organized around a single melody-generation pipeline:
launch the default configuration from
code/main.pyparse CLI settings and workflow commands in
code/app_cli.pybuild a
GenerationSettingsobjectgenerate rhythm, form targets, and harmony-aware note candidates
score candidates with melodic constraints
export LilyPond and optionally render PDF/WAV assets
Core Modules¶
melody_engine.structureDefines the core data model such as melodies, notes, time signatures, form plans, harmony plans, and voice profiles.
melody_engine.theoryHandles key spelling, Roman numeral interpretation, chord-tone targeting, and pitch conversion helpers.
melody_engine.constraintsContains the soft constraints that shape the generated melody. These include stepwise motion, leap recovery, climax control, form-section behavior, large-leap punishment, and rest usage.
melody_engine.generatorBuilds rhythm, motif targets, and note candidates, then performs weighted selection across multiple attempts to keep the best result.
melody_engine.lilypondConverts melodies to LilyPond and handles rendering to PDF, MIDI, and WAV.
code/app_cli.pyOwns the reusable command-line workflow: parsing, harmony/form setup, render mode, and generation orchestration.
code/main.pyDefines the default constraint stack and acts as the project entry point.
Current Design Priorities¶
form-aware self-similarity
harmonic awareness
voice-compatible ranges
thesis-friendly notation export
future compatibility with multi-voice and chorale generation
Chorale Direction¶
The current codebase already includes voice profiles and a ChoralePlan placeholder so the
melody engine can later be extended into SATB-style harmonization without rewriting the entire model.