AgentSkillsCN

melody-composer

创作并渲染原创旋律,生成可播放的 MIDI 和 WAV 音频文件。适用于被要求作曲、创作旋律、谱写歌曲、生成音乐作品,或打造富有音乐性的创意时使用。支持通过充分结合音乐理论的作曲方式,以完整音频渲染来表达真挚的创作意图。

SKILL.md
--- frontmatter
name: melody-composer
description: Compose and render original melodies as playable MIDI and WAV audio files. Use when asked to write music, create melodies, compose songs, generate musical pieces, or make something musical. Supports expressing genuine creative intent through music theory-informed composition with full audio rendering.

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:

  1. Identify the emotional core - what feeling should this melody evoke?
  2. Choose musical materials (scale, tempo, contour) that serve that emotion
  3. 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:

  1. Create a short motif (3-5 notes) that captures the essence
  2. Develop it: repeat, sequence (transpose), invert, extend
  3. Shape the contour - build to a climax ~62% through, then resolve
  4. 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:

json
{
    "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:

bash
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.