Melody Composer
Compose original melodies and render them as playable audio files (MIDI and WAV).
Creative Philosophy
A melody is a journey through emotional space, not an algorithm. Before writing any notes:
- •Identify the emotional core - what feeling should this melody evoke?
- •Choose musical materials (scale, tempo, contour) that serve that emotion
- •Develop ideas through variation, not random generation
Reference references/creative-approaches.md for compositional strategies.
Composition Workflow
Step 1: Define Musical Intent
Determine these parameters:
- •Emotion/Character: serenity, melancholy, joy, mystery, determination, longing
- •Tempo: BPM (60-80 calm, 90-120 moderate, 120+ energetic)
- •Mode/Scale: see
references/music-theory.md - •Form: A (8-16 bars), ABA, AABA, or through-composed
Step 2: Design the Melody
Build from a motivic seed:
- •Create a short motif (3-5 notes) that captures the essence
- •Develop it: repeat, sequence (transpose), invert, extend
- •Shape the contour - build to a climax ~62% through, then resolve
- •Vary rhythms to avoid monotony
Melodic guidelines:
- •Mostly stepwise motion, occasional leaps
- •Large leaps resolve by step in opposite direction
- •Phrase endings on stable scale degrees (1, 3, 5)
- •Leave breathing room - silence is part of melody
Step 3: Generate the Composition
Create a JSON specification with one or more voices:
{
"title": "Composition Title",
"tempo": 90,
"time_signature": [4, 4],
"voices": [
{
"name": "Melody",
"instrument": 0,
"channel": 0,
"notes": [
{"pitch": 60, "duration": 1.0, "velocity": 80, "start": 0.0}
]
},
{
"name": "Bass",
"instrument": 32,
"channel": 1,
"notes": [
{"pitch": 36, "duration": 2.0, "velocity": 70, "start": 0.0}
]
}
]
}
Voice fields:
- •
name: voice identifier (for MIDI track name) - •
instrument: General MIDI program number (see below) - •
channel: MIDI channel 0-15 (use different channels per voice) - •
notes: array of note events
Note fields:
- •
pitch: MIDI note number (60 = middle C, each semitone +1) - •
duration: length in beats (1.0 = quarter note at tempo) - •
velocity: loudness 0-127 (typical: 60-100) - •
start: beat position where note begins
Common GM instruments:
- •0: Acoustic Grand Piano
- •4: Electric Piano
- •24: Nylon Guitar
- •32: Acoustic Bass
- •40: Violin
- •42: Cello
- •48: String Ensemble
- •56: Trumpet
- •73: Flute
- •88: New Age Pad
Step 4: Render Audio
Run the composition script:
echo '<json>' | python3 scripts/compose.py output_name --wav
This creates both .mid (MIDI) and .wav (synthesized audio) files.
Quick Reference
MIDI pitches (octave 4): C=60, D=62, E=64, F=65, G=67, A=69, B=71
Common scales from C (60):
- •Major: 60, 62, 64, 65, 67, 69, 71
- •Minor: 60, 62, 63, 65, 67, 68, 70
- •Pentatonic major: 60, 62, 64, 67, 69
- •Dorian: 60, 62, 63, 65, 67, 69, 70
Emotional intervals:
- •Minor 3rd (3 semitones): sadness
- •Major 3rd (4): joy
- •Perfect 5th (7): power, stability
- •Minor 6th (8): longing
For complete theory, see references/music-theory.md.