Communitygithub.com

claude-bgm

Compose royalty-free background music (BGM) for videos, demos and streams. Use when the user asks for BGM, background music, a jingle, a loop, or "曲/BGMを作って". Claude writes a JSON score; a bundled zero-dependency Node synth renders WAV + MIDI and a numeric "ear" checks loudness, tempo, spectrum, loop seam and melody.

claude-bgm 是什么?

claude-bgm is a Claude Code agent skill that compose royalty-free background music (BGM) for videos, demos and streams. Use when the user asks for BGM, background music, a jingle, a loop, or "曲/BGMを作って". Claude writes a JSON score; a bundled zero-dependency Node synth renders WAV + MIDI and a numeric "ear" checks loudness, tempo, spectrum, loop seam and melody.

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/hatyibei/claude-bgm/tree/HEAD/skill

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

claude-bgm 是做什么的?

You compose; the script performs. Every sound comes from the bundled synth (no samples, no AI audio models), so the output is free for commercial use (see README "License").

Workflow

  1. Brief → plan (silently). Decide: preset, duration, loop or not, mood, bpm, key/mode, sections.
  2. Write the score to a file such as bgm/<name>.json (format: reference/score-format.md).
  3. Render + listen with numbers: node <skill-dir>/scripts/bgm.js render bgm/<name>.json -o bgm/<name>.wav This writes .wav, .mid, .report.json and .spectrogram.png and prints a pass/fail rubric.
  4. Look at the spectrogram PNG (Read it) and the rubric. Fix every FAIL using the printed fix hints, re-render. Stop after all checks pass or after 2 revisions; tell the user what still fails.
  5. Report: file paths, duration, LUFS, peak, and the rubric score.

Composition rules (these matter most — DAW-style auto-composition tends to give weak melodies)

  • Motif first. Write 1–2 motifs of 2 bars each in motifs, then build the melody from them: repeat ("A"), sequence up/down by scale steps ("A+1", "A-2"), end on the tonic ("A^"), invert ("A*"). Aim for ~60% of melody bars being a motif or its variation. Call-and-response: A (question, ends on 2 or 5) then A^ or B (answer, ends on 1 or 3).
  • Contour = steps. A step is a move to an adjacent degree (3→4, 6→5) or a repeated note. A third (3→5) already counts as a leap. At least 6 of every 10 note-to-note moves must be steps — including the move from the end of one phrase to the start of the next. Chord arpeggios (1-3-5) are for keys, not the melody. At most one leap per bar; after a leap, step back the other way. Range about an octave (e.g. degrees 3..10). One clear high point per section.
  • Strong beats (beat 1 and 3) land on chord tones of the chord underneath. Passing notes go on off-beats.
  • Rhythm. Mix long (1.5–2 beats) and short (0.5) notes; start some phrases on an off-beat (r:.5 5:.5 ...). Use the same rhythm for a motif and its variations so it is recognisable.
  • Leave space. BGM sits under narration: rests between phrases (r:2), melody sounding ~40–70% of the time, intro without melody, one section with a thinner arrangement.
  • Arc. ≥3 sections with different energy (e.g. intro 0.45 → A 0.65 → B 0.85 → outro 0.6). Thicken by layers (keys arp → bass pulse → drums), not by volume. Even the thinnest section needs two layers (e.g. pad + keys, or pad + bass) and energy ≥ 0.35, otherwise it drops >10 LU below the rest (fails dynamics).
  • Low end. One low-end source at a time carries the groove: busy bass (pulse8, octave) with four drums is enough; for calmer sections use "bass": "root" or "sustain".
  • Loops. For "loop": true keep the last section close in energy to the first and end on a chord that leads back to the first (V or IV → I). The renderer wraps reverb tails so the seam is seamless.
  • Fit the length. bars × beatsPerBar × 60 / bpm ≈ durationSec (the renderer nudges bpm up to ±12% to fit). 60 s at 4/4: 112 bpm → 28 bars, 120 bpm → 30 bars, 90 bpm → 22–23 bars, 75 bpm → 19 bars.

Self-check before you write the file

  1. Count the moves inside each motif: ≥60% steps? If not, fill the leaps with passing notes.
  2. Are ≥ half of the melody entries motif refs (A, A+1, A^, B...) rather than one-off phrases?
  3. Do bars add up (| warnings) and does bars × beatsPerBar × 60 / bpm ≈ durationSec? For "loop": false the renderer adds a 2 s ring-out inside durationSec, so plan the bars for durationSec − 2.

Presets

node <skill-dir>/scripts/bgm.js presets — corporate (bright product demo), lofi (swung, dusty), ambient (calm explainer bed, no drums needed), tech (driving SaaS/dev-tool demo). Each sets instruments, mix, swing, sidechain and reverb; the score only needs notes and arrangement.

The ear (what the rubric checks)

Audio: integrated LUFS −16.5..−13.5, peak ≤ −1 dBFS, no clipping, no silence gaps, duration ±1 s, audible tempo, loop seam, spectral balance, loudness range 1–9 LU. Score: melody range 7–19 semitones, ≥50% stepwise, motif repetition ≥40% of bars, ≥3 note lengths, ≥70% chord tones on strong beats, ≤10% out of key, ≥3 sections with energy range ≥0.2, melody 30–85% of the time. node <skill-dir>/scripts/bgm.js analyze file.wav --score score.json --png spec.png checks any WAV.

相关技能