dynamic-staff-notation
/dynamic-staff-notation
Tworzy interaktywną partyturę HTML do śpiewu: szuka melodii piosenki, odtwarza nuta po nucie i podświetla tekst.
- Autor
- zuiaitudou233-hash ↗
- Repozytorium
- staff-notation ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 28.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 13
- Skrypty
- 2
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 28.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 2 skrypty w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: assets/vexflow/vexflow-bravura.js, scripts/generate_notation.py
Co robi i kiedy
Tworzy interaktywną partyturę HTML do śpiewu: szuka melodii piosenki, odtwarza nuta po nucie i podświetla tekst.
Wyzwalacze z opisu
Oryginalny opis (EN)
Generate dynamic, interactive staff notation (动态五线谱) HTML pages for singing assistance. Given a song name, searches for the song's melody data (sheet music, chord charts, or MIDI data) and generates a full interactive HTML page with VexFlow-rendered staff notation, note-by-note playback, tempo control, transposition, auto-scroll, and lyrics highlighting. The output rhythm faithfully reflects the original song (with dotted notes, sixteenth notes, ties, and long notes — not uniform eighth-note filler). Use when user says "生成五线谱", "制作动态五线谱", "staff notation", "sheet music for", "唱歌辅助", "制谱", "给这首
Jak działa
- Workflow
- Researching Song Data
- Constructing Notation JSON
- Using the Script
- Template
- Best Practices
- Troubleshooting
- Resources
- Example: Generating Notation for a Song
Podgląd SKILL.md
---
name: dynamic-staff-notation
description: Generate dynamic, interactive staff notation (动态五线谱) HTML pages for singing assistance. Given a song name, searches for the song's melody data (sheet music, chord charts, or MIDI data) and generates a full interactive HTML page with VexFlow-rendered staff notation, note-by-note playback, tempo control, transposition, auto-scroll, and lyrics highlighting. The output rhythm faithfully reflects the original song (with dotted notes, sixteenth notes, ties, and long notes — not uniform eighth-note filler). Use when user says "生成五线谱", "制作动态五线谱", "staff notation", "sheet music for", "唱歌辅助", "制谱", "给这首歌做五线谱", "动态五线谱", or asks for any musical notation visualization for singing practice. Output is always a standalone interactive HTML file.
---
# Dynamic Staff Notation (动态五线谱)
Generate interactive staff notation HTML pages for singing assistance. Given a song name, research its melody and produce a full interactive notation page.
## Workflow
1. **Research song data** — Search the web for the song's key, melody notes, and lyrics
2. **Construct notation JSON** — Encode the melody as structured note data
3. **Validate with script** — Run `generate_notation.py` to validate the data
4. **Generate interactive HTML** — Embed notation into the template, producing the final page
5. **Open for the user** — Present the HTML for the user to open and interact with
## Researching Song Data
Use web search (firecrawl-search or similar) to find:
- **Key and time signature**: Search for "`<song name>` key time signature"
- **Melody notes**: Search for "`<song name>` sheet music melody notes", or "`<song name>` 简谱" for Chinese songs
- **Lyrics**: Search for the song lyrics, broken into syllables/phrases per measure
- **Chord progression**: Helpful context for key determination
For Chinese songs (中文歌曲), "简谱" (numbered musical notation) searches are often the most productive — they provide the scale-degree numbers (do=1, re=2, etc.) which you can convert to actual pitches in the song's key.
### 优先使用结构化曲谱(避免凭图片猜谱)
- **苍强曲谱(cangqiang.com.cn)**:有声曲谱页内嵌完整简谱 DSL,直接给出调号、拍号、BPM 和逐字歌词,是最可靠的机器可读来源。搜索 `歌名 苍强` 或 `歌名 有声曲谱 简谱`。
- 拿到页面 HTML 后读取 `context.keynote`(如 `1=D`)、`context.rhythm`(如 `4/4`)、`context.notation`(简谱 DSL)、`context.lyric`(歌词数组)。
- 可用其播放器 JS(`yun.cangqiang.com/bofang/bofan/hc_*.js`)解析展开重复得到完整线性音序,或按下方 DSL 规则自行转写。
- 图片谱(qupu123 等)只做交叉核对;不要仅凭听感或大致音高编谱。
#### 苍强 DSL 符号速查
| 符号 | 含义 | 示例 |
|------|------|------|
| `1-7` | 音级(do-re-mi...) | `5` = sol |
| `0` | 休止符 | `0_` = 八分休止 |
| `_` | 八分音符(1 条下划线) | `2_` |
| `=` | 十六分音符(2 条下划线) | `2=` |
| `.` | 附点 | `2_.` = 附点八分 |
| `,` | 低八度 | `6,` = 低音 la |
| `g` / `'` | 高八度 | `1g` = 高音 do |
| `-` | 延音一拍(附到前一个音符) | `6--` = 6 再延 2 拍 |
| `(...)` | 连音/符杠分组,不改变时值 | `(2=3=)` |
| `|` | 小节线;`||` 段落线;`|:`/`:|` 反复 | `\|6,_3_0_2=1=\|` |
| `[1:` / `[2:` | 第一/第二结尾(反复) | `[1:...]||[2:...]` |
注意:`=` 在这里表示**十六分音符**(两条下划线),不是数学等号;行首独立的 `.` 是附点,要挂到前一个音符上(如 `1g\n.7=` 表示附点高音 1)。
### Converting 简谱 (Numbered Notation) to Pitches
简谱 uses numbers 1-7 for scale degrees. Convert to actual pitches based on the key:
1. Determine the key (e.g. C major)
2. Map the scale degrees: 1=C, 2=D, 3=E, 4=F, 5=G, 6=A, 7=B
3. Dots above (高音): add one octave (e.g. in C, `1̇` = C/5)
4. Dots below (低音): subtract one octave (e.g. in C, `1̲` = C/3)
5. Underline (时值减半): eighth or 16th notes based on number of underlines
6. Dash after note (时值加倍): longer duration
Example for "月亮代表我的心" in C major:
```
5̲ 3̲ | 3̲ 2̲ 1̲ | 1̲ 6 | 5 - |
月 亮 代 表 我 的 心
```
Becomes: G/3 E/3 | E/3 D/3 C/3 | C/3 A/3 | G/3
## Constructing Notation JSON
Build a JSON object with this structure:
```json
{
"title": "月亮代表我的心",
"composer": "汤尼 (翁清溪)",
"key": "C",
"timeSignature": "4/4",
"pickupBeats": 1, // 可选:首小节弱起拍数(如 4/4 里 1 拍弱起)
"measureKeys": ["A", null, "Bb"], // 可选:每小节调号,转调段写新调(如 A -> Bb)
"bpm": 80,
"notes": [
{ "pitch": "G/3", "duration": "h", "lyric": "月" },
{ "pitch": "E/3", "duration": "q", "lyric": "亮" },
{ "pitch": "E/3", "duration": "q", "lyric": "代" },
{ "pitch": "D/3", "duration": "q", "lyric": "表" },
{ "pitch": "C/3", "duration": "q", "lyric": "我" },
{ "pitch": "C/3", "duration": "h", "lyric": "的" },
{ "pitch": "A/3", "duration": "q", "lyric": "心" },
{ "pitch": "G/3", "duration": "w", "lyric": "" }
]
}
```
### Note object fields:
| Field | Required | Description | Example |
|-------|----------|-------------|---------|
| `pitch` | Yes | Note + accidental + octave | `C/4`, `F#/4`, `Bb/3`, `r` (rest) |
| `duration` | Yes | Note length code | `w`, `h`, `q`, `e`, `s`, `t` |
| `lyric` | No | Lyric syllable for this note | `月`, `love`, `你` |
| `dots` | No | Number of augmentation dots | `0`, `1`, `2` |
| `stem` | No | Stem direction | `up`, `down`, `auto` |
| `accidental` | No | Explicit accidental | `#`, `b`, `n` |
### Duration reference:
- `w` = whole (4 beats in 4/4)
- `h` = half (2 beats)
- `q` = quarter (1 beat)
- `e` = eighth (1/2 beat)
- `s` = 16th (1/4 beat)
- `t` = 32nd (1/8 beat)
### Dotted notes: add `"dots": 1` for a dotted rhythm (e.g. dotted quarter = q + e).
## Using the Script
The `scripts/generate_notation.py` helper validates and generates the final HTML.
### Validate only:
```bash
python3 scripts/generate_notation.py --validate < notation.json
```
### Generate HTML (output to stdout):
```bash
python3 scripts/generate_notation.py < notation.json > song.html
```
### Generate HTML with output file:
```bash
python3 scripts/generate_notation.py output.html < notation.json
```
### Interactive mode (guided construction):
```bash
python3 scripts/generate_notation.py --interactive
```
## Template
The HTML template is at `assets/staff-notation-template.html`. It loads the vendored `assets/vexflow/vexflow-bravura.js` (no CDN needed). The template supports:
- **Play/Pause** — Note-by-note playback with visual highlighting
- **Tempo slider** — Adjust BPM from 40-200
- **Transposition** — Shift key up/down by semitones
- **Octave shift** — Change octave for vocal range
- **Auto-scroll** — Follow the current note automatically
- **Now-playing indicator** — Shows current pitch and lyric in a floating bar
### Features for singing assistance:
- Each note is highlighted as it plays
- Lyrics are displayed under each note
- The current pitch name is shown in the now-playing bar
- Tempo can be adjusted mid-playback
- Can transpose to a comfortable key for the singer's range
- Auto-scroll keeps the current measure visible
## Best Practices
### Vocal Range
- Most comfortable singing range: **C/4 to C/5** (middle octave)
- For male singers, notation at C/3-C/4 may be more appropriate (sounds an octave lower)
- Use the transpose and octave shift controls to adjust on the fly
### Rhythm Rules (铁律)
- **每小节时值必须精确等于拍号**(如 4/4 = 4 拍,附点按 1.5/1.75 倍计入)。生成前务必运行 `generate_notation.py --validate`(含逐小节拍数校验),拍数超标或不足的小节必须修正后才能生成
- **原谱小节线不一定等于拍号小节**:很多简谱(尤其苍强)用 2 拍一小节,或前奏混有 1 拍弱起/4 拍小节,必须按目标拍号重新组合成 4/4
- **跨小节音符的处理**:4/4 重排时若长音跨小节,拆成两个同音连续时值(技能允许的延音替代写法),歌词只标第一段,续奏段 `"lyric": ""`
- **弱起小节**:歌曲开头若有 1 拍弱起,JSON 加 `"pickupBeats": 1`,生成器/模板已支持;首小节只占该拍数,其余小节严格等于拍号
- **末尾小节**:不足 4 拍时用休止符补齐,保证逐小节校验通过
- **节奏必须符合实际歌曲,禁止全用同一时值平铺**:
- 简谱图中实际出现的附点(如 `2̇.`)、十六分音符(数字下方双下划线)、延音线(`-`)、二分/全音符长音都必须如实标注
- 禁止把简谱图上有附点/十六分/延音的小节简化为"清一色 8 分音符"——这是最常见的节拍错误,**会导致生成的谱与原曲律动完全不符**
- 前奏/间奏通常有 16 分音符扫弦 + 附点二分/全音符长音(吉他 riff 节奏型)
- 副歌末尾常用 4 分音符或二分音符作为"延长音"(如"我当…月光"的"光"字)
**标准节奏型参考(每小节严格 4 拍)**:
| 段落 | 节奏模式 | 拍数计算 |
|------|---------|---------|
| 前奏/间奏 | `s s s s h.` | 0.25×4 + 3 = 4 拍(4×16 分扫弦 + 附点二分延音)|
| 主歌/预副歌/桥段 | `e e e e e e e e` | 0.5×8 = 4 拍(8 音 8 分,保留全部歌词)|
| 主歌末尾延音 | `e e e e e e q` | 0.5×6 + 1 = 4 拍(6 字 8 分 + 1 字 4 分延音,如"华""丈")|
| 副歌 | `e e e e e e e e h r:q r:e` | 0.5×8 + 2 + 1 + 0.5 = 4 拍(8 音 8 分 + 末尾二分延音)|
| 尾 | `w` 或 `h + h` | 4 拍(长音收束)|
**拍数速查**:`w=4, h=2, q=1, e=0.5, s=0.25, t=0.125`,附点 ×1.5(双附点 ×1.75)。常用组合:`e×8=4`(主歌)、`e×6+q=4`(主歌末尾延音)、`e×8+h+r:q+r:e=4`(副歌末尾延音)。
### Jianpu Notation Encoding
**简谱数字显示规范**:
- **高音区**:数字上方加 `.`(如 `6.` = 高八度 6)
- **低音区**:数字下方加 `,`(如 `6,` = 低八度 6)
- **中音区**:不加点
- **8 分音符**:数字下方加下划线 `_`
- **16 分音符**:数字下方加双下划线 `==`
- **32 分音符**:数字下方加三下划线 `===`
- **休止符**:显示 `0` + 时值标记(如 `0 _` 表示 8 分休止,`0 - -` 表示二分休止)
- 简谱数字用红/橙色(#e94560)显示在音符上方,歌词用黑色(#333)显示在音符下方
**中文简谱转写规则**:
- 下加点 = 低八度(/3),不加点 = 中音(/4),上加点 = 高八度(/5)
- 单下划线 = 八分音符,双下划线 = 十六分音符,数字后附点 = 附点音符
- `-` 每道 = 延长一拍
- **简谱延音线在 VexFlow 中没有原生对应**,常用替代方案:① 同音的更长时值(`h` 或 `h.`);② 用休止符占位(`r:e` / `r:q` / `r:h`);③ 拆分为两个同音的连续时值(如 `B/5:q + B/5:q` 表示 1 拍 + 延 1 拍)
### Encoding Tips
- **主歌/预副歌/桥段保留全部歌词**(每小节 8 字 8 分音符)+ **末尾关键位置用 4 分音符延音**(如"华""丈""光""郎"等)
- **歌词处理**:每字对应一个音符,一字多音只标首音;主歌每小节 8 字 8 分音符保留全部歌词,末尾关键位置用 4 分音符延音
- Place lyrics on the note where each syllable is sung
- For melismas (multiple notes per syllable), put lyric on first note only
- Include rests between phrases for realistic timing
- **禁止凭听感/和弦猜音高**:必须对照真实谱面(图片 OCR 或结构化 DSL)逐音转写
- **歌词逐字对齐**:优先使用曲谱自带的歌词段(苍强 `lyric` 数组里的 `/` 是空位/延音标记),再人工核对一遍
- **转调段落**:中途转调用 `"measureKeys"` 数组按小节标记新调号(如 A → Bb),模板会为该小节绘制新调号并按新调显示简谱数字,避免把所有临时升降号堆在一种调号里
- 推荐用"每行一小节"的构建脚本组织数据(参考 `scripts/build_guyongzhe.py`、`scripts/build_miaotang.py`):先按简谱逐小节转写并校验拍数,再输出 notation.json
## Troubleshooting
### VexFlow Rendering Pitfalls
- **附点必须写进 `StaveNote` 初始化对象**(`{ keys, duration, dots: n }`)才计入 Voice 拍数;只用 `Dot.buildAndAttach` 附点不计 ticks,该小节会报 `IncompleteVoice` 且整小节不渲染。时值字符串里的附点记号是 `d`(如 `'8d'`),不是 `'.'`
- **`Beam.draw()` 不接受参数**,必须 `beam.setContext(ctx).draw()`,否则报 `NoContext` 且符杠不渲染(音符变旗杆)
- 排查渲染问题时用无头 Chrome 抓控制台:`chrome --headless --no-sandbox --enable-logging=stderr --v=0 --screenshot=x.png "file:///...html"`,模板会把每小节的异常打到 `Render error on measure N`
## Resources
- `references/music-notation-guide.md` — Detailed reference for pitch notation, key signatures, vocal ranges, and 简谱 conversion
- `scripts/generate_notation.py` — Validation and HTML generation tool
- `assets/staff-notation-template.html` — Interactive VexFlow-based rendering template
- **`references/staff-notation-rules.md`** — **权威规范文档**(五线谱基本乐理知识、可靠谱子来源、生成规则、渲染修复记录)
- `examples/` — 可直接运行的示例数据:正确节奏、节奏被拍平、小节超拍(后者会被 `--validate` 拒绝)
## Example: Generating Notation for a Song
```bash
# 1. Create notation.json with melody data
# 2. Validate:
python3 scripts/generate_notation.py --validate < notation.json
# 3. Generate:
python3 scripts/generate_notation.py output.html < notation.json
# 4. Open the HTML file in the browser
open output.html
```
Pliki w paczce (13)
- .gitignore 1 KB
- LICENSE 1 KB
- README.md 7 KB
- SKILL.md 14 KB
- assets/staff-notation-template.html 30 KB
- assets/vexflow/vexflow-bravura.js 711 KB
- examples/01-correct-rhythm.json 1 KB
- examples/02-flattened-rhythm.json 1 KB
- examples/03-overflow-measure.json 1 KB
- examples/demo.html 33 KB
- references/music-notation-guide.md 3 KB
- references/staff-notation-rules.md 16 KB
- scripts/generate_notation.py 14 KB
Wersje
W bazie nie ma innych skilli o nazwie dynamic-staff-notation.
Migawka bazy z 13.11.2026 · wersja paczki 5666321ba3e0 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 2 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90song-from-idea
Prowadzi od pomysłu, postaci lub riffa do gotowego arkusza piosenki: formy, tempa, akordów, melodii i tekstu. - 100song2karaoke
Zamienia nagranie piosenki w pakiet karaoke: oddziela wokal, tworzy nuty i wideo z tekstem, a potem sprawdza synchronizację. - 100xiapan-music
Generuje gotowe piosenki AI, muzykę instrumentalną i BGM z opisu lub tekstu, a także pisze słowa i sprawdza saldo. - 100chordpro
Pracuje z zapisami akordów ChordPro i iReal Pro przez CLI chordsketch: renderuje do tekstu, HTML lub PDF, transponuje, sprawdza błędy, porządkuje źródło i konwertuje tekst, ABC oraz MusicXML na ChordPro. - 100audio-to-midi
Konwertuje pliki MP3, WAV i FLAC do MIDI i MusicXML z analizą muzyczną, silnikami Basic Pitch i Piano Model oraz opcjonalną separacją ścieżek Demucs. - 100suno-forge
Pisze teksty piosenek i tagi stylu dla Suno AI dopasowane do kontekstu, w kompletnym pliku utworu do 5000 znaków.