Skip to content

A toolbox of film styles made in code for Claude Code: 66 ready to use, and your own. Each style is a style prompt plus a demo film made entirely in code by Claude Opus 5.5, with no video model. By Lemomo. · 一套用代码做片的风格工具箱:66 种现成风格,也能做出你自己的

Demos are reference implementations; add a style name index

lemomo-ai81b5cfc8cf13
diff --git a/AGENTS.md b/AGENTS.md
index 4714193..a454061 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -6,9 +6,11 @@ This repository is a library of film styles. Each style is a prompt (`styles/<sl
1. [`DIRECTOR.md`](DIRECTOR.md): how to direct (story, sound, rhythm, camera, performance, checks).
2. [`TECHNIQUE.md`](TECHNIQUE.md): how to build it (render(t) pages, voice, music, mix, review).
-3. `styles/<slug>/STYLE.md` for the chosen style. §1–§8 define the style. §9 is the recipe of our demo: reuse it, don't copy the demo's story.
+3. `styles/<slug>/STYLE.md` for the chosen style. §1–§8 define the style. §9 shows how our demo was built. The demo is a reference implementation: learn and reuse its techniques, but don't rebuild it or copy its story.
-If the user hasn't picked a style, show them the list (`styles/`, or the gallery in `styleboard/index.html`) and suggest two or three that fit their topic.
+**Finding the style.** Users name a style by its gallery name in English or Chinese ("Impasto Oil Painting", "油画厚涂") or by its folder (`impasto`). Look it up in [`styles/README.md`](styles/README.md), which maps every name to its folder. If nothing matches clearly, show the closest two or three and ask.
+
+If the user hasn't picked a style, show them the list in `styles/README.md` (or the gallery in `styleboard/index.html`) and suggest two or three that fit their topic.
## Workflow
@@ -26,14 +28,14 @@ Report progress in the user's language. The film's own language is whatever the
- Work only in `films/<name>/` (ignored by git), unless the user asks you to work in their own project.
- `core/` has ready-made tools (rendering, TTS, speech check, sampler, sfx, mux). Use them or your own stack, but don't edit `core/` or `styles/` for a user's film.
-- Large assets are fetched on demand: `sh tools/fetch.sh voice | instruments | hdri | demo <slug>`.
+- Large assets are fetched on demand: `sh tools/fetch.sh voice | instruments | hdri`.
- Never kill processes you didn't start. Don't leave background processes running.
## Maintaining the library (repository owner only)
To add a new style:
-1. Make it in `styles/<slug>/`: `STYLE.md` in English, following the §1–§9 structure of an existing one; `TREATMENT.md`; `demo/` with `build.sh` and `CREDITS`; `<slug>.mp4`, `<slug>.srt`, `poster.jpg`, and `demo/stills/styleframe.jpg`.
+1. Make it in `styles/<slug>/`: `STYLE.md` in English, following the §1–§9 structure of an existing one; `TREATMENT.md`; `demo/` with the demo's source (a reference implementation, not a rebuild kit) and `CREDITS`; `<slug>.mp4`, `<slug>.srt`, `poster.jpg`, and `demo/stills/styleframe.jpg`.
2. Add a card to `styleboard/cards.json`: film title, one-line story in English and Chinese, and use cases.
3. Run `sh tools/publish.sh`. It checks the repo (no files over 5 MB, no absolute paths, no secrets), uploads new or changed films to GitHub Releases, and rebuilds the gallery data.
4. Commit and push. The gallery (GitHub Pages) rebuilds itself.
diff --git a/TECHNIQUE.md b/TECHNIQUE.md
index 516bafd..b0719f3 100644
--- a/TECHNIQUE.md
+++ b/TECHNIQUE.md
@@ -26,7 +26,6 @@ Large assets are not in git. Fetch them when a step needs them:
sh tools/fetch.sh voice # Kokoro TTS model (~340 MB) → core/tts/
sh tools/fetch.sh instruments # CC0 / CC BY sample libraries (~1.35 GB) → core/audio/instruments/
sh tools/fetch.sh hdri # Poly Haven HDRIs for 3D styles → core/assets/polyhaven/
-sh tools/fetch.sh demo <slug> # fonts, music and other inputs to rebuild one of our demos
```
## 2. The picture is a function of time
@@ -130,4 +129,4 @@ Only CC0, CC BY or OFL material, each listed in the film's `CREDITS` file with i
| 3D with depth of field and real materials | `styles/brick-toy/`, `styles/paper-popup/` |
| a CRT or VHS look | `core/post/crt.js`, `styles/ascii-crt/`, `styles/backrooms/` |
-Each style's `STYLE.md` §9 is the exact recipe for its demo, and `demo/build.sh` rebuilds it end to end.
+Each style's `STYLE.md` §9 shows how its demo was built. Treat our demos as reference implementations: read them to see how a technique works, then write your own film. They are not kits for rebuilding our films.
diff --git a/core/README.md b/core/README.md
index 389e4bd..ab884d0 100644
--- a/core/README.md
+++ b/core/README.md
@@ -38,6 +38,6 @@ demo 是一个静态页面 `styles/<slug>/demo/index.html`(仓库根作为静
## 参考实现
- `styles/brick-toy/`:3D(three.js)+ 物理 + 景深,STYLE.md 是标准格式
-- `styles/scifi-toon/`:2D 矢量卡通、角色口型、原创配乐、build.sh 一键重现
+- `styles/scifi-toon/`:2D 矢量卡通、角色口型、原创配乐
- `styles/cel-anime-80s/`:2D 赛璐璐、角色设定表流程、CRT 后期、配乐 fork 子 agent
- 三者 `STYLE.md` 的 §8 记录了踩过的坑,开工前读
diff --git a/docs/zh-CN/TECHNIQUE.md b/docs/zh-CN/TECHNIQUE.md
index bef5da2..24d2646 100644
--- a/docs/zh-CN/TECHNIQUE.md
+++ b/docs/zh-CN/TECHNIQUE.md
@@ -26,7 +26,6 @@
sh tools/fetch.sh voice # Kokoro 配音模型(约 340 MB)→ core/tts/
sh tools/fetch.sh instruments # CC0 / CC BY 采样库(约 1.35 GB)→ core/audio/instruments/
sh tools/fetch.sh hdri # 3D 风格用的 Poly Haven 环境光 → core/assets/polyhaven/
-sh tools/fetch.sh demo <slug> # 重建我们某支样片所需的字体、配乐等输入
```
## 2. 画面是时间的函数
@@ -130,4 +129,4 @@ export const HIT = { pratfall: ['chase', 6], ... }; // 段落 + 第几拍
| 带景深和真实材质的 3D | `styles/brick-toy/`、`styles/paper-popup/` |
| CRT / 录像带质感 | `core/post/crt.js`、`styles/ascii-crt/`、`styles/backrooms/` |
-每个风格 `STYLE.md` 的 §9 是这支样片的完整做法,`demo/build.sh` 可以从头重建它。
+每个风格 `STYLE.md` 的 §9 记录了这支样片是怎么做的。我们的样片是参考实现:读它们,看某个技法怎么实现,再写你自己的片子。它们不是用来重建我们原片的套件。
diff --git a/styleboard/build.py b/styleboard/build.py
index 6b9351c..4403caf 100644
--- a/styleboard/build.py
+++ b/styleboard/build.py
@@ -165,6 +165,23 @@ for fn in ('README.md',):
t2 = re.sub(r'(<!-- styles:start -->\n).*?(<!-- styles:end -->)', lambda m: m.group(1) + readme_grid() + m.group(2), t, flags=re.S)
if t2 != t: open(p, 'w', encoding='utf-8').write(t2)
+def style_index():
+ """styles/README.md:风格名(英文 / 中文)→ 文件夹。agent 按用户说的风格名在这里查到对应的 STYLE.md。"""
+ out = ['# Style index · 风格索引', '',
+ 'Users may name a style in English, in Chinese, or by its folder. Find it here, then read `styles/<folder>/STYLE.md`.',
+ '用户可能用英文名、中文名或文件夹名来指定风格。在这里查到文件夹,再读 `styles/<文件夹>/STYLE.md`。', '<!-- generated by styleboard/build.py from styleboard/catalog.json; do not edit by hand -->', '']
+ for cn, en in cats:
+ group = [x for x in styles if x['cat'] == cn and x['stylemd']]
+ if not group: continue
+ out += [f'## {en} · {cn}', '', '| Style | 风格 | Folder | Our demo |', '|---|---|---|---|']
+ out += [f'| {s["en"]} | {s["cn"]} | [`{s["slug"]}`]({s["slug"]}/STYLE.md) | *{s["film"]}* |' for s in group]
+ out.append('')
+ return '\n'.join(out)
+
+
+if not site:
+ open(os.path.join(ROOT, 'styles', 'README.md'), 'w', encoding='utf-8').write(style_index())
+
print(f'{len(styles)} styles ({n_vid} with film, {minutes:.0f} min) → {os.path.relpath(os.path.join(out_dir, "index.html"), ROOT)}')
for s in styles:
if not s['imgs']: print(' no image:', s['slug'])
diff --git a/styles/README.md b/styles/README.md
new file mode 100644
index 0000000..bfdd8a3
--- /dev/null
+++ b/styles/README.md
@@ -0,0 +1,89 @@
+# Style index · 风格索引
+
+Users may name a style in English, in Chinese, or by its folder. Find it here, then read `styles/<folder>/STYLE.md`.
+用户可能用英文名、中文名或文件夹名来指定风格。在这里查到文件夹,再读 `styles/<文件夹>/STYLE.md`。
+<!-- generated by styleboard/build.py from styleboard/catalog.json; do not edit by hand -->
+
+## Hand-drawn & Painting · 手绘与绘画
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Crayon Picture Book | 蜡笔儿童绘本 | [`crayon-book`](crayon-book/STYLE.md) | *The Moon Can't Sleep* |
+| Watercolor Brush | 水彩笔刷 | [`watercolor`](watercolor/STYLE.md) | *Follow the Rain* |
+| Chinese Ink Wash | 中国水墨 | [`ink-wash`](ink-wash/STYLE.md) | *The Swordsman and the River* |
+| Impasto Oil Painting | 油画厚涂 | [`impasto`](impasto/STYLE.md) | *The Colour of Rain* |
+| One-line Drawing | 一笔画 | [`one-line`](one-line/STYLE.md) | *The Line That Never Lifted* |
+| Whiteboard Explainer | 白板讲解 | [`whiteboard`](whiteboard/STYLE.md) | *Einstein in Your Pocket* |
+| Urban Sketch · Pen & Wash | 钢笔淡彩 | [`urban-sketch`](urban-sketch/STYLE.md) | *Where the Wind Went* |
+
+## East Asian Traditions · 东方传统
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Shadow Puppetry | 皮影戏 | [`shadow-puppet`](shadow-puppet/STYLE.md) | *Hou Yi Shoots the Suns* |
+| Ukiyo-e | 浮世绘 | [`ukiyoe`](ukiyoe/STYLE.md) | *A Journey Toward the Mountain* |
+| Red Paper-cut | 红色窗花剪纸 | [`papercut-red`](papercut-red/STYLE.md) | *Nian Comes to Town* |
+| Paper-cut Lightbox | 纸雕灯影 | [`paper-lantern`](paper-lantern/STYLE.md) | *A Mooncake's Longing* |
+
+## Print & Printmaking · 印刷与版画
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Risograph Print | Risograph 丝网印刷 | [`risograph`](risograph/STYLE.md) | *Sunday Ride* |
+| Halftone Dossier | 复古半调案卷 | [`halftone-dossier`](halftone-dossier/STYLE.md) | *Case File: Chubby* |
+| Woodcut Print | 木刻版画 | [`woodcut`](woodcut/STYLE.md) | *The Bell Founder* |
+
+## Graphic & Type · 图形与排版
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Swiss Motion Graphics | 瑞士动态排版 | [`swiss-motion`](swiss-motion/STYLE.md) | *Five Rules for a Poster* |
+| 60s Spy Title Sequence | 60s 间谍片头 | [`spy-titles`](spy-titles/STYLE.md) | *The Velvet Cipher* |
+| Art Deco | 装饰艺术 | [`art-deco`](art-deco/STYLE.md) | *Midnight at the Starlight Hotel* |
+| Blueprint | 蓝图 / 工程制图 | [`blueprint`](blueprint/STYLE.md) | *Patent Pending: The Cloud Catcher* |
+| Stained Glass | 彩色玻璃窗 | [`stained-glass`](stained-glass/STYLE.md) | *The Dragon of the East Window* |
+| Pictogram Motion | 象形运动图形 | [`pictogram-motion`](pictogram-motion/STYLE.md) | *Aichi-Nagoya 2026 — All 43 Sports* |
+| ASCII / CRT Terminal | ASCII / CRT 终端 | [`ascii-crt`](ascii-crt/STYLE.md) | *Tranquility.log* |
+
+## Information & Keynote · 信息与发布
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Data Storytelling | 数据叙事 | [`dataviz`](dataviz/STYLE.md) | *A Hundred Summers* |
+| Isometric Infographic | 等距信息图 | [`iso-infographic`](iso-infographic/STYLE.md) | *From Bean to Cup* |
+| Dark Tech Keynote | 暗色科技发布 | [`dark-keynote`](dark-keynote/STYLE.md) | *Room to Think* |
+| Living Screencast | 活体实机录屏 | [`living-screencast`](living-screencast/STYLE.md) | *Clawd Moves In* |
+
+## Cartoon & Anime · 卡通与动画
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| 1930s Rubber Hose Cartoon | 1930s 橡皮管卡通 | [`rubber-hose`](rubber-hose/STYLE.md) | *Coffee Cup Chase* |
+| 80s Cel Anime | 80 年代赛璐璐动画 | [`cel-anime-80s`](cel-anime-80s/STYLE.md) | *City Lights, 1987* |
+| Sci-Fi Sitcom Toon | 科幻情景喜剧卡通 | [`scifi-toon`](scifi-toon/STYLE.md) | *Coffee Run* |
+
+## Games · 游戏
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| 16-bit Pixel RPG | 16-bit 像素 RPG | [`pixel-rpg`](pixel-rpg/STYLE.md) | *The Last Save Point* |
+| HD-2D | HD-2D | [`hd-2d`](hd-2d/STYLE.md) | *The Lampbearer* |
+| Microgame Frenzy | 微游戏快闪(瓦里奥制造式) | [`microgame`](microgame/STYLE.md) | *Five-Second Astronaut* |
+| Game Show Flat | 综艺节奏扁平 | [`game-show`](game-show/STYLE.md) | *Rhythm of AI, 1997 → 2026* |
+
+## Cinema & Eras · 电影与时代
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| 1920s Silent Film | 1920s 默片 | [`silent-film`](silent-film/STYLE.md) | *The Runaway Loaf* |
+| Liminal Found Footage | 后室 / 新怪谈 | [`backrooms`](backrooms/STYLE.md) | *Night Shift Orientation* |
+
+## Materials & 3D · 材质与 3D
+
+| Style | 风格 | Folder | Our demo |
+|---|---|---|---|
+| Brick Toy | 积木玩具 | [`brick-toy`](brick-toy/STYLE.md) | *Rocket from Spare Parts* |
+| Paper Pop-up Book | 纸片立体书 | [`paper-popup`](paper-popup/STYLE.md) | *Pip's Paper Adventure* |
+| Tilt-Shift Miniature | 移轴微缩 | [`tilt-shift`](tilt-shift/STYLE.md) | *Toy Town Rush Hour* |
+| Low-poly Isometric Island | 低多边形等距 | [`lowpoly-island`](lowpoly-island/STYLE.md) | *The Island That Grew* |
+| Glass Product Render | 玻璃质感产品 | [`glass-product`](glass-product/STYLE.md) | *Aura — Hear the Light* |
diff --git a/styles/brick-toy/demo/CREDITS b/styles/brick-toy/demo/CREDITS
new file mode 100644
index 0000000..1b96d9f
--- /dev/null
+++ b/styles/brick-toy/demo/CREDITS
@@ -0,0 +1,12 @@
+Rocket from Spare Parts — Brick Toy demo · LemoLab × Claude Opus 5.5 · asset sources & licenses
+
+Music Kevin MacLeod (incompetech.com), licensed under Creative Commons: By Attribution 4.0
+ "Monkeys Spinning Monkeys", "Heroic Age" — edited to the picture by music/edit.py
+Sound FX Synthesized in code (mix.py + core/audio/sfx.py). No samples.
+Voices Kokoro TTS v1.0 (kokoro-onnx), Apache-2.0 — bm_george (narrator), am_adam (radio)
+3D assets Poly Haven, CC0 (see core/assets/polyhaven/SOURCES.md):
+ photo_studio_loft_hall HDRI, american_walnut_veneer texture, tea_set_01, desk_lamp_arm_01
+Bricks Brick geometry, characters and the rocket built procedurally in code (bricks.js / actors.js / rockets.js).
+ Generic interlocking-brick shapes only; no LEGO logos, minifigure designs or set models.
+Font Fredoka (core/fonts) — Google Fonts, SIL Open Font License 1.1
+Code three.js (MIT)
diff --git a/styles/cel-anime-80s/demo/CREDITS.md b/styles/cel-anime-80s/demo/CREDITS
similarity index 100%
rename from styles/cel-anime-80s/demo/CREDITS.md
rename to styles/cel-anime-80s/demo/CREDITS
diff --git a/styles/crayon-book/demo/CREDITS_v2 b/styles/crayon-book/demo/CREDITS_v2
deleted file mode 100644
index 9a73944..0000000
--- a/styles/crayon-book/demo/CREDITS_v2
+++ /dev/null
@@ -1,14 +0,0 @@
-The Moon Can't Sleep — Crayon Picture Book demo · LemoLab × Claude Opus 5.5
-
-Story, characters, animation, crayon/watercolour engine, sound design: original (procedural code in this folder).
-Music: original score (demo/music/score.py). Lullaby melody, motifs and arrangement are original.
- Samples (CC0 1.0): VS Chamber Orchestra: Community Edition — Versilian Studios / Sam Gossner
- (flute, flute staccato, clarinet, clarinet staccato);
- Versilian Community Sample Library — Versilian Studios (glockenspiel, harp).
- Music box: physical/modal synthesis, core/audio/pluck.py (no samples). Toy piano: numpy synthesis.
-Voice: Kokoro TTS v1.0 (Apache-2.0), voice bf_emma.
-Fonts (SIL Open Font License 1.1, licence files in demo/fonts/):
- Patrick Hand — Patrick Wagesreiter (subtitles, book text)
- Gaegu — JIKJI SOFT (title, "The End")
- Short Stack, Gochi Hand, Caveat Brush, Sniglet — downloaded for tests, not used in the film.
-Reference for grammar only (nothing copied): Raymond Briggs, "The Snowman" (1982).
diff --git a/styles/crayon-book/demo/build_v2.sh b/styles/crayon-book/demo/build_v2.sh
deleted file mode 100755
index f65a8c1..0000000
--- a/styles/crayon-book/demo/build_v2.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-# 从零重现成片:sh styles/crayon-book/demo/build.sh (任意目录运行均可)
-set -e
-cd "$(dirname "$0")/../../.."
-PY=.venv/bin/python; D=styles/crayon-book/demo
-$PY core/tts/tts.py $D/lines.json $D/voices # 1. Kokoro 配音 bf_emma
-$PY core/tts/asr_check.py $D/lines.json $D/voices # 2. whisper 逐句校对
-node core/render/events.mjs $D # 3. 时间线 → events.json(旁白/拟音/配乐 cue/星星显现)
-$PY $D/music/score.py # 4. 原创配乐(音乐盒/玩具钢琴/长笛/单簧管/钟琴)→ music/score.wav
-$PY $D/mix.py # 5. 拟音 + 旁白 + 配乐闪避 + 底噪 → mix.wav
-node $D/subs.mjs && $PY core/render/srt.py $D/subs.json styles/crayon-book/crayon-book.srt # 6. 字幕
-node core/render/video.mjs $D --fps 24 --workers 3 --out $D/out/video24.mp4 # 7. 逐帧渲染
-CRF=26 sh $D/tools/mux.sh $D/out/video24.mp4 $D/mix.wav styles/crayon-book/crayon-book.mp4 24 0 # 8. 合成 + −14 LUFS(纸纹已是颗粒,不再加;CRF 26)
diff --git a/styles/crayon-book/demo/events_v2.json b/styles/crayon-book/demo/events_v2.json
deleted file mode 100644
index 384e055..0000000
--- a/styles/crayon-book/demo/events_v2.json
+++ /dev/null
@@ -1 +0,0 @@
-{"dur":52,"ev":[{"t":5.5,"type":"voice","id":"n1"},{"t":8.05,"type":"voice","id":"n2"},{"t":15.3,"type":"voice","id":"n3"},{"t":20.4,"type":"voice","id":"n4"},{"t":24.9,"type":"voice","id":"n5"},{"t":40.2,"type":"voice","id":"n6"},{"t":49.2,"type":"voice","id":"n7"},{"t":0.3,"type":"scratch","dur":0.45,"pan":-0.3},{"t":0.6,"type":"scratch","dur":0.6,"pan":-0.2},{"t":0.9,"type":"scratch","dur":0.7,"pan":0.5},{"t":1.7,"type":"scratch","dur":0.7,"pan":-0.7},{"t":1.67,"type":"pop","pan":0.5},{"t":2.6,"type":"write","dur":1.6,"pan":-0.5},{"t":2.6,"type":"scribble","dur":1,"pan":0.5},{"t":3,"type":"scribble","dur":1,"pan":-0.1},{"t":3.3,"type":"scribble","dur":1,"pan":-0.2},{"t":3.6,"type":"scribble","dur":1,"pan":-0.2},{"t":4,"type":"scribble","dur":0.8,"pan":-0.7},{"t":0,"type":"paper"},{"t":7.5,"type":"toss","pan":0.3},{"t":9.17,"type":"toss","pan":0.3},{"t":10.75,"type":"hop","i":0,"pan":0},{"t":10.2,"type":"baa","i":0,"pan":-0.4},{"t":10.6,"type":"number","i":0},{"t":11.583,"type":"hop","i":1,"pan":0},{"t":11.033,"type":"baa","i":1,"pan":-0.30000000000000004},{"t":11.433,"type":"number","i":1},{"t":12.417,"type":"hop","i":2,"pan":0},{"t":11.867,"type":"baa","i":2,"pan":-0.2},{"t":12.267,"type":"number","i":2},{"t":13.25,"type":"hop","i":3,"pan":0},{"t":12.7,"type":"baa","i":3,"pan":-0.09999999999999998},{"t":13.1,"type":"number","i":3},{"t":14.083,"type":"hop","i":4,"pan":0},{"t":13.533,"type":"baa","i":4,"pan":0},{"t":13.933,"type":"number","i":4},{"t":13.95,"type":"silence","dur":1},{"t":14.3,"type":"cricket","pan":-0.6},{"t":18.33,"type":"wave"},{"t":20.3,"type":"rung","i":0},{"t":20.75,"type":"rung","i":1},{"t":21.2,"type":"rung","i":2},{"t":21.65,"type":"rung","i":3},{"t":22.1,"type":"rung","i":4},{"t":22.55,"type":"rung","i":5},{"t":23,"type":"rung","i":6},{"t":23.45,"type":"rung","i":7},{"t":19.75,"type":"hopout"},{"t":24,"type":"climbover"},{"t":24.6,"type":"step"},{"t":25,"type":"step"},{"t":25.4,"type":"step"},{"t":25.8,"type":"step"},{"t":26.4,"type":"sit"},{"t":27.9,"type":"brush","dur":2,"dir":1},{"t":30,"type":"brush","dur":2.1000000000000014,"dir":-1},{"t":32.5,"type":"brush","dur":2.200000000000003,"dir":1},{"t":27.6,"type":"dip"},{"t":28.544,"type":"glint","pan":-0.4136360027594492},{"t":29.01,"type":"glint","pan":0.12836846681311725},{"t":29.486,"type":"glint","pan":0.6813210970256478},{"t":30.287,"type":"glint","pan":0.8444463642546907},{"t":30.41,"type":"glint","pan":0.7082983288681135},{"t":29.068,"type":"glint","pan":0.19529199799289926},{"t":28.305,"type":"glint","pan":-0.691765985393431},{"t":31.189,"type":"glint","pan":-0.15353922351496294},{"t":31.721,"type":"glint","pan":-0.7430341948871501},{"t":28.51,"type":"glint","pan":-0.4529050140408799},{"t":29.709,"type":"glint","pan":0.9404360662680119},{"t":28.706,"type":"glint","pan":-0.22608127867570146},{"t":29.656,"type":"glint","pan":0.8783609448582865},{"t":31.53,"type":"glint","pan":-0.5316161684109829},{"t":29.033,"type":"glint","pan":0.1544533269130625},{"t":31.885,"type":"glint","pan":-0.9242182340822183},{"t":28.442,"type":"glint","pan":-0.5322293266304768},{"t":29.341,"type":"glint","pan":0.5125060714781284},{"t":28.991,"type":"glint","pan":0.10543403390329331},{"t":28.991,"type":"glint","pan":0.10581037133233621},{"t":28.463,"type":"glint","pan":-0.5079005268635228},{"t":29.038,"type":"glint","pan":0.16039234797935933},{"t":31.485,"type":"glint","pan":-0.4813990455237217},{"t":30.254,"type":"glint","pan":0.8808459293679334},{"t":34.005,"type":"glint","pan":0.4278589098248631},{"t":28.538,"type":"glint","pan":-0.42049910975620153},{"t":31.384,"type":"glint","pan":-0.36966354158939796},{"t":29.35,"type":"glint","pan":0.5226576848770492},{"t":29.148,"type":"glint","pan":0.28874490049201995},{"t":29.179,"type":"glint","pan":0.3244467979646288},{"t":29.599,"type":"glint","pan":0.8128771915915423},{"t":31.41,"type":"glint","pan":-0.398674242105335},{"t":28.741,"type":"glint","pan":-0.1853996067191474},{"t":31.488,"type":"glint","pan":-0.48517356826923785},{"t":28.96,"type":"glint","pan":0.06933651451254264},{"t":29.618,"type":"glint","pan":0.8350039719371125},{"t":29.049,"type":"glint","pan":0.17341017992002888},{"t":29.667,"type":"glint","pan":0.8912459406070411},{"t":30.234,"type":"glint","pan":0.9034238818567246},{"t":29.645,"type":"glint","pan":0.8665436755400151},{"t":29.045,"type":"glint","pan":0.1686698445584625},{"t":31.366,"type":"glint","pan":-0.3496197884436697},{"t":31.923,"type":"glint","pan":-0.9661706292419694},{"t":34.055,"type":"glint","pan":0.48058065176010134},{"t":30.508,"type":"glint","pan":0.5995677651255391},{"t":28.891,"type":"glint","pan":-0.009957486356142908},{"t":30.713,"type":"glint","pan":0.37347671821480616},{"t":30.212,"type":"glint","pan":0.9272800189093686},{"t":28.786,"type":"glint","pan":-0.1323885493213311},{"t":31.638,"type":"glint","pan":-0.650998342980165},{"t":29.29,"type":"glint","pan":0.4535066083772108},{"t":30.35,"type":"glint","pan":0.7750433835200965},{"t":29.532,"type":"glint","pan":0.7350718148052693},{"t":28.954,"type":"glint","pan":0.06233730555977672},{"t":29.516,"type":"glint","pan":0.7157010147348046},{"t":28.752,"type":"glint","pan":-0.17241324288770557},{"t":29.13,"type":"glint","pan":0.2668914037174545},{"t":31.602,"type":"glint","pan":-0.6111633338732645},{"t":32.768,"type":"glint","pan":-0.8797540091327392},{"t":29.717,"type":"glint","pan":0.9502954330528155},{"t":30.484,"type":"glint","pan":0.6262304747826419},{"t":34.003,"type":"glint","pan":0.42622590428218243},{"t":28.673,"type":"glint","pan":-0.263720005354844},{"t":31.565,"type":"glint","pan":-0.570083465706557},{"t":28.995,"type":"glint","pan":0.11045892160618678},{"t":29.281,"type":"glint","pan":0.44345787540078163},{"t":31.43,"type":"glint","pan":-0.4202419143752195},{"t":28.814,"type":"glint","pan":-0.10027541150338948},{"t":30.287,"type":"glint","pan":0.8446708652190864},{"t":31.263,"type":"glint","pan":-0.235272686148528},{"t":30.28,"type":"glint","pan":0.8527145152911544},{"t":29.583,"type":"glint","pan":0.7937496144440956},{"t":28.552,"type":"glint","pan":-0.40446407727431505},{"t":30.668,"type":"glint","pan":0.4224249752936885},{"t":28.779,"type":"glint","pan":-0.14112548892153426},{"t":28.608,"type":"glint","pan":-0.33946893552783874},{"t":31.371,"type":"glint","pan":-0.3551879593636841},{"t":29.174,"type":"glint","pan":0.3186041934415698},{"t":28.456,"type":"glint","pan":-0.5157305815257132},{"t":30.172,"type":"glint","pan":0.9717550231958739},{"t":31.865,"type":"glint","pan":-0.9018146555987187},{"t":31.782,"type":"glint","pan":-0.8108716115355492},{"t":29.528,"type":"glint","pan":0.7304914310574532},{"t":29.392,"type":"glint","pan":0.5717124336515553},{"t":30.184,"type":"glint","pan":0.9592994983540848},{"t":28.847,"type":"glint","pan":-0.06115342770935968},{"t":28.854,"type":"glint","pan":-0.05312871979549527},{"t":31.109,"type":"glint","pan":-0.06558298473246396},{"t":34.242,"type":"glint","pan":0.6780477126594633},{"t":34.146,"type":"glint","pan":0.5769150028936565},{"t":28.849,"type":"glint","pan":-0.05875233515398577},{"t":28.719,"type":"glint","pan":-0.21078649680130185},{"t":31.864,"type":"glint","pan":-0.901035439199768},{"t":33.909,"type":"glint","pan":0.32700086566619574},{"t":31.77,"type":"glint","pan":-0.7969490249175578},{"t":28.915,"type":"glint","pan":0.017311199381947518},{"t":31.128,"type":"glint","pan":-0.0865570570458658},{"t":30.855,"type":"glint","pan":0.21574575140839442},{"t":34.294,"type":"glint","pan":0.7334170249407179},{"t":28.511,"type":"glint","pan":-0.4521420134115033},{"t":28.506,"type":"glint","pan":-0.4580121592269279},{"t":28.573,"type":"glint","pan":-0.37986633345717563},{"t":28.661,"type":"glint","pan":-0.27790738265030085},{"t":34.146,"type":"glint","pan":0.577277131320443},{"t":28.669,"type":"glint","pan":-0.26878313332563264},{"t":29.147,"type":"glint","pan":0.2869262126740068},{"t":30.679,"type":"glint","pan":0.4111632218468003},{"t":28.509,"type":"glint","pan":-0.4542957006138749},{"t":28.515,"type":"glint","pan":-0.4481056724558584},{"t":30.547,"type":"glint","pan":0.5564318230957724},{"t":29.431,"type":"glint","pan":0.6174667825223878},{"t":37.5,"type":"cap","dur":0.7},{"t":38.3,"type":"yawn","who":"moon"},{"t":40,"type":"quilt","dur":1.6},{"t":41.7,"type":"tuck"},{"t":42,"type":"tuck"},{"t":43.3,"type":"yawn","who":"girl"},{"t":44.1,"type":"liedown"},{"t":46,"type":"room"},{"t":47.6,"type":"page","dur":1.2},{"t":0,"type":"cue","id":"A"},{"t":7.5,"type":"cue","id":"B"},{"t":15,"type":"cue","id":"C"},{"t":20,"type":"cue","id":"D"},{"t":27.5,"type":"cue","id":"E"},{"t":37.5,"type":"cue","id":"F"},{"t":45,"type":"cue","id":"G"}]}
\ No newline at end of file
diff --git a/styles/crayon-book/demo/film_v2.js b/styles/crayon-book/demo/film_v2.js
deleted file mode 100644
index 73ff742..0000000
--- a/styles/crayon-book/demo/film_v2.js
+++ /dev/null
@@ -1,247 +0,0 @@
-// 正片时间线:一镜到底在同一页画上移动;45s 后拉出成书页(end.js)
-import { layer, clear, line, fill, dab, text, handCircle, ellipse, CAM, BOIL, W, H, sx, sy } from './crayon.js';
-import { group, clearGroup, part } from './rig.js';
-import { girl, sheep, moon, star } from './chars.js';
-import { drawWorld, drawLadder, drawStars, drawWash, bandFront, BANDS, STARS, HOUSE, MOON, LAD, ridgeY, pr } from './world.js';
-import { PAL } from './pal.js';
-import { clamp, lerp, hash, track, ss, eio, eo } from '/core/lib.js';
-import { endFrame } from './end.js';
-const K = PAL.crayon;
-const POSTER = new URLSearchParams(location.search).get('poster') === '1';
-export const DUR = 52;
-const BPM = 72, BEAT = 60 / BPM, BAR = BEAT * 3;
-
-// —— 旁白与字幕(t = 语音起点;字幕停留 ≥1.8s 且 ≥ 语音 + 0.6s)——
-export const LINES = [
- { id: 'n1', t: 5.5, d: 1.726, text: 'The moon could not sleep.' },
- { id: 'n2', t: 8.05, d: 2.554, text: 'It tossed, and it turned, and it counted sheep.' },
- { id: 'n3', t: 15.3, d: 2.449, text: 'Down below, someone else was awake, too.' },
- { id: 'n4', t: 20.4, d: 2.39, text: 'So she climbed up, up, up, onto the roof,' },
- { id: 'n5', t: 24.9, d: 2.153, text: 'and sang the softest song she knew.' },
- { id: 'n6', t: 40.2, d: 2.289, text: 'And at last, the moon fell asleep.' },
- { id: 'n7', t: 49.2, d: 1.235, text: 'Night, night.' },
-];
-export const SUBS = LINES.map((L, i) => { const t0 = L.t - 0.1; let t1 = Math.max(t0 + 1.8, L.t + L.d + 0.7); const nx = LINES[i + 1]; if (nx) t1 = Math.min(t1, nx.t - 0.25); return { t0, t1, text: L.text }; });
-
-// —— 镜头(世界坐标中心 + 缩放),单调三次插值 ——
-const camT = track([
- [0, [1600, 900, 0.6]], [5.6, [1600, 900, 0.6]], [8.2, [2420, 650, 1.35]], [14.9, [2420, 650, 1.35]],
- [17.6, [1960, 1130, 0.88]], [19.8, [1960, 1130, 0.88]], [20.9, [1795, 1480, 1.7]], [21.6, [1795, 1480, 1.7]],
- [22.6, [1795, 1425, 1.7]], [23.5, [1795, 1355, 1.7]], [24.2, [1790, 1290, 1.55]], [27.1, [2110, 800, 0.75]], [37.4, [2110, 800, 0.75]],
- [40.0, [2400, 610, 1.25]], [42.4, [2410, 600, 1.3]], [43.3, [1458, 955, 2.0]], [44.8, [1458, 955, 2.0]], [46.0, [1600, 900, 0.6]],
-]);
-
-// —— 事件(拟音/配乐 cue,导出给 mix.py)——
-export const EV = [];
-const ev = (t, type, o = {}) => EV.push({ t: +t.toFixed(3), type, ...o });
-LINES.forEach(L => ev(L.t, 'voice', { id: L.id }));
-// 开场画线、涂色
-[[0.3, 0.45, 'draw', -0.3], [0.6, 0.6, 'draw', -0.2], [0.9, 0.7, 'draw', 0.5], [1.7, 0.7, 'draw', -0.7]].forEach(([t, d, ty, pan]) => ev(t, 'scratch', { dur: d, pan }));
-ev(1.67, 'pop', { pan: 0.5 });
-ev(2.6, 'write', { dur: 1.6, pan: -0.5 });
-[[2.6, 1.0, 0.5], [3.0, 1.0, -0.1], [3.3, 1.0, -0.2], [3.6, 1.0, -0.2], [4.0, 0.8, -0.7]].forEach(([t, d, pan]) => ev(t, 'scribble', { dur: d, pan }));
-ev(0, 'paper');
-// 翻身
-[7.5, 9.17].forEach(t => ev(t, 'toss', { pan: 0.3 }));
-// 数羊
-const SHEEP_T = [0, 1, 2, 3, 4].map(i => 10.0 + BEAT * i);
-SHEEP_T.forEach((t, i) => { ev(t + 0.75, 'hop', { i, pan: 0 }); ev(t + 0.2, 'baa', { i, pan: -0.4 + i * 0.1 }); ev(t + 0.6, 'number', { i }); });
-ev(13.95, 'silence', { dur: 1.0 }); ev(14.3, 'cricket', { pan: -0.6 });
-ev(18.33, 'wave');
-// 爬梯
-export const RUNG_T = [0, 1, 2, 3, 4, 5, 6, 7].map(i => 20.3 + 0.45 * i);
-const STEP_T = [0, 1, 2, 3, 4].map(n => 20.3 + 0.45 * (n + 3));
-RUNG_T.forEach((t, i) => ev(t, 'rung', { i }));
-ev(19.75, 'hopout'); ev(24.0, 'climbover');
-[24.6, 25.0, 25.4, 25.8].forEach(t => ev(t, 'step'));
-ev(26.4, 'sit');
-// 唱歌与刷子
-BANDS.forEach(b => ev(b.t0, 'brush', { dur: b.t1 - b.t0, dir: b.dir }));
-ev(27.6, 'dip');
-// 星星显现:刷子前沿经过每颗星的时刻
-STARS.forEach(s => { const b = BANDS.find(b => s.y >= b.y0 - 20 && s.y <= b.y1 + 20) || BANDS[2]; const u = b.dir > 0 ? (s.x + 260) / 3720 : (3460 - s.x) / 3720; const t = b.t0 + (b.t1 - b.t0) * clamp(u); if (s.big) ev(t, 'glint', { pan: (s.x - 1600) / 1600 }); });
-ev(37.5, 'cap', { dur: 0.7 }); ev(38.3, 'yawn', { who: 'moon' }); ev(40.0, 'quilt', { dur: 1.6 }); ev(41.7, 'tuck'); ev(42.0, 'tuck');
-ev(43.3, 'yawn', { who: 'girl' }); ev(44.1, 'liedown');
-ev(46.0, 'room'); ev(47.6, 'page', { dur: 1.2 });
-// 配乐 cue
-[['A', 0], ['B', 7.5], ['C', 15], ['D', 20], ['E', 27.5], ['F', 37.5], ['G', 45]].forEach(([id, t]) => ev(t, 'cue', { id }));
-
-// —— 层 ——
-const STAR = group(), BG = { f: layer(), l: layer() }, MN = group(), SH = group(), GL = group(), WASH = layer(), FX = layer(), SUBK = layer(), SUBT = layer();
-const wo = (x, y) => [x, y];
-
-// 女孩的状态机:返回 girl() 参数
-const SEAT = [1452, 1032];
-function girlState(t) {
- const sheepIn = (P, o = {}) => (Pp) => sheep(GL, { x: Pp([o.at || [4, -128]])[0][0], y: Pp([o.at || [4, -128]])[0][1], s: o.s ?? 0.78, r: o.r ?? 0, flip: o.flip, seed: 3350, eyesClosed: o.closed });
- const S = 0.56;
- if (t < 19.75) {
- // 被窝里:17.8 抬头,18.33 起挥手,笑
- const waving = t > 18.2 && t < 19.6;
- const wv = Math.floor(t * 6) % 2;
- const arms = waving ? { R: wv ? [[34, -182], [80, -200], [94, -252]] : [[34, -182], [86, -206], [112, -246]] } : {};
- return { x: 1548, y: 1602, s: 0.44, view: 'front', pose: 'bed', expr: t > 18.2 ? 'smile' : 'awake', arms, bed: true, seed: 3000 };
- }
- if (t < 20.2) { // 从窗口跳下来
- const u = pr(t, 19.75, 20.2); const x = lerp(1560, 1740, u), y = lerp(1560, 1640, u) - 90 * Math.sin(u * Math.PI);
- return { x, y, s: S, view: 'side', pose: 'stand', expr: 'awake', seed: 3000, sheep: sheepIn(null, { at: [-6, -130], flip: true }) };
- }
- if (t < 24.0) { // 背面爬梯
- let n = -1; for (let i = 0; i < STEP_T.length; i++) if (t >= STEP_T[i]) n = i;
- const yOf = k => k < 0 ? 1640 : LAD.rung(k) + 4;
- const tn = n >= 0 ? STEP_T[n] : 20.2; const u = eo(pr(t, tn, tn + 0.22));
- const y = n >= 0 ? lerp(yOf(n - 1), yOf(n), u) : 1640;
- const reach = t < STEP_T[0] ? (t > 20.3 ? 1 : 0) : 0;
- return { x: 1792, y, s: S, view: 'back', pose: 'climb', ph: (n + 1) % 2, expr: 'awake', seed: 3000, sheep: sheepIn(null, { at: [4, -128], r: -0.2 }) };
- }
- if (t < 26.25) { // 上屋顶,往屋脊走(侧面朝左)
- const u = pr(t, 24.3, 26.2); const x = lerp(1850, SEAT[0] + 20, u), y = lerp(1306, SEAT[1] + 2, u) - Math.abs(Math.sin(u * Math.PI * 4)) * 10;
- const ph = Math.floor(t * 4) % 2;
- const legs = ph ? [[[4, -90], [14, -50], [18, -12]], [[-6, -90], [-14, -50], [-20, -12]]] : [[[4, -90], [-6, -50], [-10, -12]], [[-6, -90], [6, -50], [10, -12]]];
- return { x, y, s: S, view: 'side', pose: 'stand', flip: true, legs, r: 0.12, expr: 'awake', seed: 3000, sheep: sheepIn(null, { at: [-8, -130], flip: true }) };
- }
- // 坐在屋脊上
- let expr = 'awake';
- if (t > 27.5 && t < 36.0) { const inPh = [[27.6, 29.8], [30.0, 32.3], [32.5, 34.8], [35.0, 36.0]].some(([a, b]) => t > a && t < b); expr = inPh ? 'sing' : 'awake'; }
- else if (t >= 36.0 && t < 43.2) expr = t > 41.3 ? 'sleepy' : 'smile';
- else if (t >= 43.2 && t < 44.0) expr = 'yawn';
- if (t < 44.0) {
- const tilt = t > 27.3 ? -0.3 : -0.18;
- return { x: SEAT[0], y: SEAT[1], s: S, view: 'side', pose: 'sit', hug: true, headTilt: tilt + (expr === 'sing' ? -0.04 * Math.sin(t * 5) : 0), expr, seed: 3000, sheep: sheepIn(null, { at: [46, -58], s: 0.72 }) };
- }
- if (t < 44.3) return { x: SEAT[0], y: SEAT[1], s: S, view: 'side', pose: 'sit', hug: true, headTilt: -0.4, r: -0.55, expr: 'sleep', seed: 3000, sheep: sheepIn(null, { at: [46, -58], s: 0.72, r: -0.55, closed: true }) };
- const sl = Math.atan2(-40, 620);
- return { x: SEAT[0] - 40, y: SEAT[1] + 6, s: S, view: 'side', pose: 'lieback', flip: true, r: sl, expr: 'sleep', seed: 3000, breathe: true, sheep: sheepIn(null, { at: [-58, -112], s: 0.74, r: sl, flip: true, closed: true }) };
-}
-
-// 月亮的状态
-function moonState(t) {
- const o = { x: MOON.x, y: MOON.y, s: MOON.R, seed: 700, expr: 'wide', look: [0, 0], r: 0 };
- o.lineDraw = pr(t, 0.9, 1.6); o.fillDraw = pr(t, 2.6, 3.6);
- if (t < 1.67) { o.face = false; return o; }
- if (t > 6.4 && t < 6.56) o.lid = 1;
- if (t >= 7.5 && t < 10) {
- if (t < 8.33) { o.expr = 'grumpy'; o.r = -0.35 + 0.04 * Math.sin(t * 20); }
- else if (t < 9.17) { o.expr = 'wide'; }
- else if (t < 9.9) { o.expr = 'grumpy'; o.r = 0.35 + 0.04 * Math.sin(t * 20); }
- }
- if (t >= 10 && t < 13.95) { o.expr = 'look'; const sx_ = sheepX(t); o.look = [clamp((sx_ - MOON.x) / 420, -1, 1), 0.35]; }
- if (t >= 13.95 && t < 15) { o.expr = 'wide'; o.eyeK = 1.15; }
- const toGirl = [-0.75, 0.66];
- if (t >= 15 && t < 27.5) { o.expr = t > 18.33 && t < 19.8 ? 'smile' : 'look'; o.look = toGirl; }
- if (t >= 27.5 && t < 37.5) { o.expr = 'look'; o.look = [lerp(-0.75, -0.3, pr(t, 27.5, 37)), lerp(0.66, 0.3, pr(t, 27.5, 37))]; o.lid = 0.5 * pr(t, 30, 37); }
- if (t >= 37.5) { o.cap = pr(t, 37.5, 38.2); o.expr = 'drowsy'; o.lid = 0.6; }
- if (t >= 38.3 && t < 39.2) { o.expr = 'yawn'; o.yawnK = 0.6 + 0.6 * Math.sin(pr(t, 38.3, 39.2) * Math.PI); }
- if (t >= 39.2) { o.expr = 'asleep'; o.lid = 0; }
- o.r += -1.0 * ss(pr(t, 38.6, 40.0));
- if (t >= 40.0) { o.blanket = ss(pr(t, 40.0, 41.6)); o.hand = t < 42.3 ? 1 : 0; o.tuck = t > 41.6 && t < 42.3 ? pr(t, 41.6, 42.3) * 2 : 0; }
- if (t > 39.2) o.s = MOON.R * (1 + 0.012 * Math.sin(t * 2.2));
- return o;
-}
-// 数羊:第 i 只的位置
-function sheepPos(i, t) {
- const t0 = SHEEP_T[i], u = (t - t0) / 1.5; if (u < 0 || u > 1) return null;
- const q = Math.floor(u * 1.5 * 12) / (1.5 * 12); // 12fps 步进
- const x = lerp(1640, 3260, q), y = 960 - 330 * Math.sin(q * Math.PI);
- return { x, y, r: i === 4 && q > 0.55 ? Math.sin((q - 0.55) * 30) * 0.25 : (q - 0.5) * 0.3 };
-}
-function sheepX(t) { let best = MOON.x; for (let i = 0; i < 5; i++) { const p = sheepPos(i, t); if (p && p.x > 1900 && p.x < 3000) best = p.x; } return best; }
-
-// —— 渲染一帧 ——
-export function frame(comp, t) {
- if (t >= 46.0) return endFrame(comp, t, { drawPage, subTo });
- drawPage(comp, t, camT(t), { vig: 0.3 * (1 - pr(t, 45, 46)) });
-}
-export function drawPage(comp, t, cam, { subs = true, vig = 0.3 } = {}) {
- [CAM.x, CAM.y, CAM.s] = cam;
- BOIL.amp = t > 44.4 ? 0.55 : 1;
- clearGroup(STAR); clearGroup(MN); clearGroup(SH); clearGroup(GL);
- [BG.f, BG.l, WASH, FX, SUBK, SUBT].forEach(clear);
- // 开场画出来的进度
- const p = { hl: pr(t, 0.3, 1.2), hf: pr(t, 3.0, 4.3), tl: pr(t, 1.7, 2.3), tf: pr(t, 4.0, 4.8), gl: pr(t, 1.8, 2.4), gf: pr(t, 3.6, 4.6), wf: pr(t, 3.6, 4.4) };
- drawWorld(BG.f, BG.l, p);
- if (p.hf >= 1) drawStars(STAR);
- // 片名(写在纸上)
- if (t > 2.6) {
- text(BG.l, 'The Moon', sx(110), sy(210), { size: 140 * CAM.s, font: 'Gaegu', weight: 700, reveal: pr(t, 2.6, 3.3), seed: 21, p: 0.95, stroke: 2, align: 'left' });
- text(BG.l, "Can't Sleep", sx(150), sy(345), { size: 140 * CAM.s, font: 'Gaegu', weight: 700, reveal: pr(t, 3.35, 4.2), seed: 29, p: 0.95, stroke: 2, align: 'left' });
- }
- // 数羊的数字
- SHEEP_T.forEach((t0, i) => { if (t > t0 + 0.6) text(BG.l, String(i + 1), sx(1860 + 78 * i), sy(390 + (i % 2) * 18), { size: 96 * CAM.s, font: 'Gaegu', weight: 700, seed: 40 + i, reveal: pr(t, t0 + 0.6, t0 + 0.8), p: 0.9 }); });
- // 梯子
- const rungs = RUNG_T.reduce((a, rt) => a + clamp((t - rt + 0.12) / 0.12), 0);
- drawLadder(BG.f, BG.l, rungs, pr(t, 20.15, 20.35) * (0.42 + 0.58 * clamp(rungs / 8)));
- // 月亮
- const mo = moonState(t);
- if (t > 0.9) moon(MN, mo);
- // 羊
- for (let i = 0; i < 5; i++) { const q = sheepPos(i, t); if (q) sheep(SH, { x: q.x, y: q.y, s: 1.8, r: q.r, seed: 900 + i * 17 }); }
- // 女孩
- if (t > 4.2) {
- const gs = girlState(t);
- girl(GL, gs);
- if (gs.bed) { // 被子 + 被窝里的小羊
- sheep(GL, { x: 1618, y: 1558, s: 0.5, seed: 3350, r: -0.1 });
- part(GL, [[1446, 1560], [1520, 1548], [1600, 1556], [1676, 1546], [1676, 1590], [1446, 1600]], { col: K.sky, p: 0.8, gap: 8, w: 10, ang: 0.2, seed: 3990 }, { w: 7, seed: 3991 });
- } else if (t < 46) part(GL, [[1446, 1566], [1676, 1556], [1676, 1590], [1446, 1600]], { col: K.sky, p: 0.8, gap: 8, w: 10, ang: 0.2, seed: 3990 }, { w: 7, seed: 3991 });
- }
- // 唱歌的音符
- if (t > 27.6 && t < 40) for (let j = 0; j < 11; j++) {
- const t0 = 27.7 + BEAT * j; if (t0 > 36) break; const u = (t - t0) / 3.2; if (u < 0 || u > 1) continue;
- const bx = SEAT[0] + 44 + 150 * u + 26 * Math.sin(u * 6 + j), by = SEAT[1] - 116 - 330 * u;
- noteGlyph(FX, bx, by, j, 1 - pr(u, 0.6, 1), pr(u, 0, 0.12));
- }
- // 星星闪烁
- if (t > 34.6) for (let k = 0; k < 16; k++) {
- const s = STARS[(k * 37) % STARS.length]; if (!s.big) continue;
- const ph = (t * 0.7 + hash(k) * 3) % 3; if (ph > 0.5) continue;
- const a = Math.sin(ph / 0.5 * Math.PI), r = s.r * (1.6 + 1.2 * a);
- line(FX, [[s.x - r, s.y], [s.x + r, s.y]], { w: 3.5, col: K.white, p: a, seed: 800 + k, wob: 0.2 });
- line(FX, [[s.x, s.y - r], [s.x, s.y + r]], { w: 3.5, col: K.white, p: a, seed: 820 + k, wob: 0.2 });
- }
- // 睡着的 z
- if (t > 44.7) for (let j = 0; j < 4; j++) { const t0 = 44.7 + j * 1.1; const u = (t - t0) / 2.4; if (u < 0 || u > 1) continue; text(FX, 'z', sx(SEAT[0] + 40 + 60 * u), sy(SEAT[1] - 70 - 140 * u), { size: (40 + 30 * u) * CAM.s, font: 'Gaegu', weight: 700, p: 1 - pr(u, 0.6, 1), seed: 60 + j }); }
- // 海报:白蜡笔写的片名(?poster=1)
- if (POSTER) { text(FX, 'The Moon', 150, 170, { size: 120, font: 'Gaegu', weight: 700, col: K.yellow, p: 1, stroke: 3, align: 'left', seed: 5 }); text(FX, "Can't Sleep", 190, 290, { size: 120, font: 'Gaegu', weight: 700, col: K.yellow, p: 1, stroke: 3, align: 'left', seed: 6 }); text(FX, 'a crayon picture book', 200, 360, { size: 46, col: K.white, p: 1, align: 'left', seed: 7 }); }
- // 水彩
- if (t > BANDS[0].t0) drawWash(WASH, t);
- // 字幕
- if (subs) subTo(SUBK, SUBT, t);
- // 合成(纸纹锚定在这一页上,跟着镜头走)
- comp.paperCam(CAM.x * 0.6, CAM.y * 0.6, CAM.s / 0.6);
- comp.begin();
- comp.group(STAR, { goff: [0, 0] });
- comp.crayon(BG.f.c); comp.crayon(BG.l.c);
- const go = [hash(BOIL.step) * 300, hash(BOIL.step + 7) * 300];
- comp.group(MN, { goff: go }); comp.group(SH, { goff: go });
- if (t > BANDS[0].t0) comp.wash(WASH.c, { color: PAL.wash });
- comp.group(GL, { goff: go }); // 女孩画在水彩之后:夜里也读得清她的脸
- comp.crayon(FX.c, { goff: go });
- comp.knock(SUBK.c); comp.crayon(SUBT.c);
- comp.finish({ vig });
-}
-function noteGlyph(L, x, y, j, p, draw) {
- const s = 1.0, c = K.ink;
- if (j % 3 === 2) { // 双音符
- line(L, [[x, y], [x, y - 44 * s]], { w: 6, col: c, seed: 1000 + j, p, draw });
- line(L, [[x + 30, y - 6], [x + 30, y - 50 * s]], { w: 6, col: c, seed: 1001 + j, p, draw });
- line(L, [[x, y - 44 * s], [x + 30, y - 50 * s]], { w: 9, col: c, seed: 1002 + j, p, draw });
- fill(L, handCircle(x - 9, y, 10, j, 0, 16), { col: c, p: 0.95 * p, gap: 3.5, w: 5, seed: 1003 + j, over: 1 });
- fill(L, handCircle(x + 21, y - 6, 10, j + 1, 0, 16), { col: c, p: 0.95 * p, gap: 3.5, w: 5, seed: 1004 + j, over: 1 });
- } else {
- line(L, [[x, y], [x, y - 44 * s]], { w: 6, col: c, seed: 1000 + j, p, draw });
- line(L, [[x, y - 44 * s], [x + 18, y - 34 * s], [x + 20, y - 22 * s]], { w: 6, col: c, seed: 1001 + j, p, draw });
- fill(L, handCircle(x - 9, y, 10, j, 0, 16), { col: c, p: 0.95 * p, gap: 3.5, w: 5, seed: 1003 + j, over: 1 });
- }
-}
-export function subTo(SUBK, SUBT, t) {
- const S = SUBS.find(s => t >= s.t0 && t < s.t1); if (!S) return;
- const rv = pr(t, S.t0, S.t0 + 0.35);
- const g = SUBK.g; g.save(); g.font = '400 54px "Patrick Hand"'; const tw = g.measureText(S.text).width; g.restore();
- // 给字留出的一块纸(不规则边)
- const cx = 960, cy = 1002, hw = tw / 2 + 46, hh = 44;
- g.save(); g.fillStyle = '#000'; g.beginPath();
- for (let i = 0; i <= 60; i++) { const a = i / 60 * Math.PI * 2; const px = Math.cos(a), py = Math.sin(a); const sq = Math.pow(Math.abs(px), 0.3) * Math.sign(px); const n = 1 + 0.06 * Math.sin(a * 7 + 1.3) + 0.03 * Math.sin(a * 17); const X = cx + sq * hw * n, Y = cy + py * hh * n; i ? g.lineTo(X, Y) : g.moveTo(X, Y); }
- g.closePath(); g.fill(); g.restore();
- text(SUBT, S.text, cx, cy + 18, { size: 54, col: K.ink, reveal: rv, seed: 11 + S.t0 * 3, p: 1, stroke: 1.2 });
-}
diff --git a/styles/crayon-book/demo/lines_v2.json b/styles/crayon-book/demo/lines_v2.json
deleted file mode 100644
index bad906d..0000000
--- a/styles/crayon-book/demo/lines_v2.json
+++ /dev/null
@@ -1,44 +0,0 @@
-[
- {
- "id": "n1",
- "text": "The moon could not sleep.",
- "voice": "bf_emma",
- "speed": 0.86
- },
- {
- "id": "n2",
- "text": "It tossed, and it turned, and it counted sheep.",
- "voice": "bf_emma",
- "speed": 0.88
- },
- {
- "id": "n3",
- "text": "Down below, someone else was awake, too.",
- "voice": "bf_emma",
- "speed": 0.86
- },
- {
- "id": "n4",
- "text": "So she climbed up, up, up, onto the roof,",
- "voice": "bf_emma",
- "speed": 0.88
- },
- {
- "id": "n5",
- "text": "and sang the softest song she knew.",
- "voice": "bf_emma",
- "speed": 0.84
- },
- {
- "id": "n6",
- "text": "And at last, the moon fell asleep.",
- "voice": "bf_emma",
- "speed": 0.82
- },
- {
- "id": "n7",
- "text": "Night, night.",
- "voice": "bf_emma",
- "speed": 0.82
- }
-]
\ No newline at end of file
diff --git a/styles/crayon-book/demo/mix_v2.py b/styles/crayon-book/demo/mix_v2.py
deleted file mode 100644
index 2539225..0000000
--- a/styles/crayon-book/demo/mix_v2.py
+++ /dev/null
@@ -1,197 +0,0 @@
-# 混音:原创配乐(music/score.wav)+ 材质拟音(蜡笔刮纸、湿刷子、毡子、纸页)+ 夜晚底噪 + 旁白 → mix.wav
-# 用法:.venv/bin/python styles/crayon-book/demo/mix.py
-import sys, os, json, numpy as np, soundfile as sf, soxr
-from scipy.ndimage import uniform_filter1d
-HERE = os.path.dirname(os.path.abspath(__file__))
-sys.path.insert(0, os.path.join(HERE, '../../../core/audio'))
-from sfx import *
-
-E = json.load(open(os.path.join(HERE, 'events.json'))); DUR = E['dur']; EV = E['ev']; N = int(DUR * SR)
-tt = np.arange(N) / SR
-rng = np.random.default_rng(12)
-def nz(d): return rng.standard_normal(int(round(d * SR)))
-def T(d): return np.arange(int(round(d * SR))) / SR
-def fade(x, a=.01, b=.03):
- n = len(x); ia, ib = min(n, int(a * SR)), min(n, int(b * SR))
- if ia: x[:ia] *= np.linspace(0, 1, ia)
- if ib: x[-ib:] *= np.linspace(1, 0, ib)
- return x
-def envelope(d, pts):
- k = np.array(pts, float); return np.interp(T(d), k[:, 0] * d, k[:, 1])
-
-# ——— 蜡笔刮纸:粘滑摩擦 = 带通噪声 × 不规则颗粒调制;speed 越快颗粒越密、越亮 ———
-def crayon(d, speed=1.0, v=1.0):
- n = nz(d); g = np.abs(rng.standard_normal(len(n)))
- rate = int(SR / (70 + 90 * speed))
- grain = uniform_filter1d((rng.random(len(n) // rate + 2) ** 3).repeat(rate)[:len(n)], rate // 3 + 1)
- x = bp(n, 1400 + 600 * speed, 6500, 2) * (0.35 + grain * 1.6) + bp(n, 300, 900, 1) * 0.15
- return fade(x * envelope(d, [(0, 0), (.08, 1), (.85, .9), (1, 0)]) * v * 0.22, .01, .04)
-# 涂色:来回排线 = 每一趟一个短刮擦
-def scribble(d, rate=6.5, v=1.0):
- out = np.zeros(int(d * SR)); k = 0; t = 0.0
- while t < d - 0.08:
- L = 1 / rate * (0.8 + 0.4 * rng.random()); s = crayon(min(L, d - t), 1.3, v * (0.7 + 0.3 * rng.random()))
- i = int(t * SR); out[i:i + len(s)] += s[:len(out) - i]; t += L; k += 1
- return out
-def write(d, v=1.0): # 写字:一小簇一小簇
- out = np.zeros(int(d * SR)); t = 0.0
- while t < d - 0.1:
- L = 0.07 + 0.1 * rng.random(); s = crayon(L, 0.8, v); i = int(t * SR); out[i:i + len(s)] += s[:len(out) - i]; t += L + 0.03 * rng.random()
- return out
-def paper_rustle(d=0.6, v=1.0):
- n = nz(d); cr = (rng.random(len(n)) < 0.004) * rng.standard_normal(len(n)) * 3
- return fade((hp(n, 900) * 0.25 + bp(cr, 1500, 8000)) * envelope(d, [(0, 0), (.2, 1), (1, 0)]) * v * 0.25)
-def blink(v=1.0):
- t = T(0.09); return fade(np.sin(2 * np.pi * (1500 - 5000 * t) * t) * np.exp(-t / 0.02) * 0.25 * v, .001, .02)
-def swish(d=0.4, v=1.0): # 被子嗖声
- n = nz(d); e = np.sin(np.linspace(0, np.pi, len(n))) ** 2
- return lp(bp(n, 250, 2500), 2200) * e * 0.35 * v
-def felt(v=1.0): # 羊落地:毡子噗
- t = T(0.22); return fade((np.sin(2 * np.pi * 105 * t) * np.exp(-t / 0.05) * 0.7 + lp(nz(0.22), 600) * np.exp(-t / 0.03) * 0.5) * v * 0.45)
-def baa(v=1.0, f0=430):
- d = 0.42; t = T(d); f = f0 * (1 + 0.02 * np.sin(2 * np.pi * 7 * t)) * (1 - 0.08 * t / d)
- ph = 2 * np.pi * np.cumsum(f) / SR; saw = 2 * ((ph / (2 * np.pi)) % 1) - 1
- x = bp(saw, 600, 1100) * 1.0 + bp(saw, 1900, 2600) * 0.5
- trem = 1 + 0.5 * np.sin(2 * np.pi * 18 * t)
- return fade(x * trem * envelope(d, [(0, 0), (.1, 1), (.7, .8), (1, 0)]) * 0.12 * v, .02, .08)
-def cricket(d=1.2, v=1.0):
- out = np.zeros(int(d * SR)); t = 0
- while t < d - 0.1:
- for k in range(3):
- tc = T(0.018); c = np.sin(2 * np.pi * 4700 * tc) * np.sin(np.pi * tc / 0.018)
- i = int((t + k * 0.026) * SR); out[i:i + len(c)] += c[:len(out) - i]
- t += 0.32 + 0.1 * rng.random()
- return out * 0.05 * v
-def tap(v=1.0, f=900): # 屋瓦上的小脚步
- t = T(0.08); return fade((bp(nz(0.08), f, f * 3) * np.exp(-t / 0.012) + np.sin(2 * np.pi * f * 0.35 * t) * np.exp(-t / 0.02) * 0.4) * 0.35 * v, .001, .02)
-def plip(v=1.0): # 刷子蘸水
- t = T(0.25); x = np.sin(2 * np.pi * np.cumsum(900 + 1400 * np.exp(-t / 0.03)) / SR) * np.exp(-t / 0.05)
- return fade(x * 0.25 * v + bp(nz(0.25), 2000, 7000) * np.exp(-t / 0.02) * 0.08 * v)
-def brush(d, v=1.0): # 湿鬃毛擦纸:柔软宽带 + 细颗粒,起落软
- n = nz(d)
- wet = lp(n, 1800) * 0.5 + bp(n, 1800, 5000) * 0.18
- grain = uniform_filter1d(np.abs(rng.standard_normal(len(n))), 400) * 0.6 + 0.7
- body = wet * grain * envelope(d, [(0, 0), (.06, .9), (.3, 1), (.8, .85), (1, 0)])
- return fade(body * 0.22 * v, .03, .1)
-def pat(v=1.0):
- t = T(0.12); return fade(lp(nz(0.12), 500) * np.exp(-t / 0.025) * 0.5 * v + np.sin(2 * np.pi * 140 * t) * np.exp(-t / 0.03) * 0.2 * v)
-def page_turn(d=1.2, v=1.0):
- out = np.zeros(int((d + 0.4) * SR))
- lift = hp(nz(0.35), 700) * envelope(0.35, [(0, 0), (.5, .6), (1, .2)]) * 0.18
- wh = bp(nz(0.6), 300, 4000) * np.sin(np.linspace(0, np.pi, int(0.6 * SR))) ** 1.5 * 0.35
- cr = (rng.random(int(0.6 * SR)) < 0.003) * rng.standard_normal(int(0.6 * SR)) * 2.5
- flap_t = T(0.25); flap = (lp(nz(0.25), 1500) * np.exp(-flap_t / 0.03) * 0.6 + np.sin(2 * np.pi * 90 * flap_t) * np.exp(-flap_t / 0.05) * 0.3)
- for x, at in [(lift, 0.0), (wh + bp(cr, 2000, 9000), 0.25), (flap, d - 0.1)]:
- i = int(at * SR); out[i:i + len(x)] += x[:len(out) - i]
- return out * v
-def tick(v=1.0, hi=True):
- t = T(0.04); return fade(bp(nz(0.04), 2500 if hi else 1800, 7000) * np.exp(-t / 0.006) * 0.12 * v, .0005, .01)
-
-buf = np.zeros((N, 2)); amb = np.zeros((N, 2))
-def put(x, at, g=1.0, pan=0.0, b=None): add(buf if b is None else b, x.astype(np.float64), at, g, pan)
-
-for e in EV:
- t, ty, pan = e['t'], e['type'], e.get('pan', 0.0)
- if ty == 'scratch': put(crayon(e['dur'], 1.1), t, 1.0, pan)
- elif ty == 'write': put(write(e['dur']), t, 0.9, pan)
- elif ty == 'scribble': put(scribble(e['dur']), t, 0.75, pan)
- elif ty == 'paper': put(paper_rustle(0.8), t, 0.8)
- elif ty == 'pop': put(blink(), t, 0.8, pan)
- elif ty == 'toss': put(swish(0.45), t - 0.05, 1.0, pan)
- elif ty == 'hop': put(felt(), t, 0.8, -0.2 + 0.15 * e['i'])
- elif ty == 'baa': put(baa(0.9, 420 + 25 * e['i']), t, 0.9, pan)
- elif ty == 'number': put(crayon(0.2, 1.4), t, 0.7, -0.6)
- elif ty == 'cricket': put(cricket(0.7), t, 1.0, pan)
- elif ty == 'rung': put(crayon(0.12, 1.6), t - 0.12, 0.8, 0.3)
- elif ty == 'hopout': put(swish(0.3, 0.6), t, 1.0, 0.1); put(felt(0.7), t + 0.42, 1.0, 0.2)
- elif ty == 'climbover': put(swish(0.4, 0.6), t, 1.0, 0.2); put(pat(0.7), t + 0.3, 1.0, 0.2)
- elif ty == 'step': put(tap(0.8), t, 1.0, -0.1)
- elif ty == 'sit': put(pat(0.8), t, 1.0, -0.2); put(swish(0.3, 0.4), t - 0.1, 1.0, -0.2)
- elif ty == 'dip': put(plip(), t, 0.9, -0.5)
- elif ty == 'brush':
- d = e['dur'] + 0.25; x = brush(d)
- # 声像跟着刷子走:分两半摆
- p0, p1 = (-0.85, 0.85) if e['dir'] > 0 else (0.85, -0.85)
- L = len(x); s = int(t * SR); pn = np.linspace(p0, p1, L)
- l, r = np.cos((pn + 1) * np.pi / 4) * 1.414, np.sin((pn + 1) * np.pi / 4) * 1.414
- e2 = min(N, s + L); buf[s:e2, 0] += (x * l)[:e2 - s]; buf[s:e2, 1] += (x * r)[:e2 - s]
- elif ty == 'cap': put(crayon(e['dur'], 1.0), t, 0.8, 0.3)
- elif ty == 'quilt': put(scribble(e['dur'], 7.5), t, 0.8, 0.3); put(swish(1.2, 0.35), t + 0.2, 1.0, 0.3)
- elif ty == 'tuck': put(pat(0.7), t, 1.0, 0.3)
- elif ty == 'liedown': put(swish(0.5, 0.5), t, 1.0, -0.1)
- elif ty == 'page': put(page_turn(e['dur']), t, 0.4, -0.1)
- elif ty == 'room':
- # 书桌那一场:暖暖的室内底噪 + 远处座钟
- d = DUR - t; x = lp(brown(d), 400) * 0.02 * envelope(d, [(0, 0), (.15, 1), (1, 1)])
- add(amb, x, t, 1.0, 0.0)
- k = 0; tc = t + 0.3
- while tc < DUR - 0.2: add(amb, tick(0.8, k % 2 == 0), tc, 1.0, 0.5); tc += 1.0; k += 1
-
-# 夜晚底噪:数羊之后很轻的蟋蟀,唱歌段更轻;书桌场景前淡出
-nb = np.zeros(N)
-for t0 in np.arange(15.0, 45.5, 1.7): x = cricket(1.2, 0.35); i = int(t0 * SR); nb[i:i + len(x)] += x[:N - i]
-nb *= np.interp(tt, [15, 16, 27, 28, 44, 45.8], [0, 1, 1, .5, .5, 0])
-amb[:, 0] += nb * 0.8; amb[:, 1] += np.roll(nb, 900) * 0.8
-# 纸面底噪:极轻的"纸"的空气声(开场到书桌)
-air = hp(nz(DUR), 3000) * 0.0025
-amb[:, 0] += air * np.interp(tt, [0, 1, 45, 46], [1, 1, 1, 0]); amb[:, 1] += np.roll(air, 2000) * np.interp(tt, [0, 1, 45, 46], [1, 1, 1, 0])
-
-# ——— 旁白:Kokoro bf_emma,24k → 48k,温暖 EQ + 轻压缩 + 小房间 ———
-LN = json.load(open(os.path.join(HERE, 'lines.json')))
-vo = np.zeros((N, 2)); vmask = np.zeros(N)
-for e in [x for x in EV if x['type'] == 'voice']:
- a, sr = sf.read(os.path.join(HERE, 'voices', e['id'] + '.wav'))
- if a.ndim > 1: a = a.mean(1)
- a = soxr.resample(a, sr, SR)
- a = a + lp(a, 250) * 0.25 - hp(a, 7000) * 0.2 # 暖一点,齿音收一点
- a = compress(a / (np.abs(a).max() + 1e-9) * 0.8, thr=.22, ratio=3.0)
- a = norm(a, 0.72)
- add(vo, a, e['t'], 1.0, 0.0)
- s = int(e['t'] * SR); vmask[s:s + len(a)] = 1
-# 小房间混响(旁白贴耳,只要一点空气)
-ir_t = T(0.35); ir = rng.standard_normal(len(ir_t)) * np.exp(-ir_t / 0.07); ir[0] = 0
-from scipy.signal import fftconvolve
-for c in range(2): vo[:, c] += fftconvolve(vo[:, c], ir * 0.003, 'full')[:N]
-
-# ——— 配乐 ———
-mp = os.path.join(HERE, 'music', 'score.wav')
-SG = {'musicbox': 1.45, 'glock': 1.4, 'toypiano': 1.0, 'flute': 1.0, 'clarinet': 1.0, 'bass': 1.0}
-stems = [os.path.join(HERE, 'music', 'stems', k + '.wav') for k in SG]
-if all(os.path.exists(p) for p in stems):
- mus = np.zeros((N, 2))
- for k, p in zip(SG, stems):
- m, msr = sf.read(p)
- if m.ndim == 1: m = np.stack([m, m], 1)
- L = min(N, len(m)); mus[:L] += m[:L] * SG[k]
- # 音乐盒和钟琴的金属光泽:3–6 kHz 轻提
- for c in range(2): mus[:, c] += bp(mus[:, c], 3000, 7000, 2) * 0.35
-elif os.path.exists(mp):
- m, msr = sf.read(mp)
- if msr != SR: m = soxr.resample(m, msr, SR)
- if m.ndim == 1: m = np.stack([m, m], 1)
- mus = np.zeros((N, 2)); L = min(N, len(m)); mus[:L] = m[:L]
-else:
- print('!! music/score.wav 不存在,先跑 music/score.py'); mus = np.zeros((N, 2))
-# 旁白下闪避约 −7 dB(平滑)
-duck = uniform_filter1d(vmask, int(0.25 * SR)); duck = np.clip(duck * 1.6, 0, 1)
-g = 1 - duck * (1 - 10 ** (-7 / 20))
-mus *= g[:, None]
-# 唱歌段是情绪最高点:没有旁白,音乐整体抬 4 dB(平滑进出)
-mus *= (10 ** (np.interp(tt, [27.0, 27.6, 37.2, 38.2], [0, 4, 4, 0]) / 20))[:, None]
-
-buf *= np.interp(tt, [0, 5, 5.5], [0.8, 0.8, 1.0])[:, None]
-mix = mus * 0.95 + buf * 1.0 + amb * 1.0 + vo * 1.0
-for c in range(2): mix[:, c] = limit(mix[:, c], .95)
-sf.write(os.path.join(HERE, 'mix.wav'), mix.astype(np.float32), SR)
-# 电平表
-def db(x): return 20 * np.log10(np.sqrt(np.mean(x ** 2)) + 1e-9)
-for name, x in [('music', mus), ('foley', buf), ('amb', amb), ('voice', vo), ('mix', mix)]: print(f'{name:6s} RMS {db(x):6.1f} dB peak {20*np.log10(np.abs(x).max()+1e-9):6.1f}')
-for a, b in [(0, 7.5), (7.5, 15), (15, 20), (20, 27.5), (27.5, 37.5), (37.5, 45), (45, 52)]:
- s, e = int(a * SR), int(b * SR); print(f'{a:5.1f}-{b:5.1f} mus {db(mus[s:e]):6.1f} fol {db(buf[s:e]):6.1f} vo {db(vo[s:e]):6.1f} mix {db(mix[s:e]):6.1f}')
-if os.environ.get('DBG'):
- fb = np.abs(buf).max(1);
- for i in np.argsort(fb)[::-1][:1]: print('foley peak at', i / SR)
- w = int(0.5 * SR)
- for k in range(0, N - w, w):
- p = np.abs(buf[k:k + w]).max()
- if p > 0.3: print(f' {k/SR:5.1f}s foley peak {p:.2f}')
diff --git a/styles/crayon-book/demo/subs_v2.json b/styles/crayon-book/demo/subs_v2.json
deleted file mode 100644
index 0f99d22..0000000
--- a/styles/crayon-book/demo/subs_v2.json
+++ /dev/null
@@ -1,37 +0,0 @@
-[
- {
- "t0": 5.4,
- "t1": 7.8,
- "text": "The moon could not sleep."
- },
- {
- "t0": 7.95,
- "t1": 11.304,
- "text": "It tossed, and it turned, and it counted sheep."
- },
- {
- "t0": 15.2,
- "t1": 18.449,
- "text": "Down below, someone else was awake, too."
- },
- {
- "t0": 20.3,
- "t1": 23.49,
- "text": "So she climbed up, up, up, onto the roof,"
- },
- {
- "t0": 24.8,
- "t1": 27.753,
- "text": "and sang the softest song she knew."
- },
- {
- "t0": 40.1,
- "t1": 43.189,
- "text": "And at last, the moon fell asleep."
- },
- {
- "t0": 49.1,
- "t1": 51.135,
- "text": "Night, night."
- }
-]
\ No newline at end of file
diff --git a/styles/crayon-book/demo/voices_v2/dur.json b/styles/crayon-book/demo/voices_v2/dur.json
deleted file mode 100644
index 5c30f9c..0000000
--- a/styles/crayon-book/demo/voices_v2/dur.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "n1": 1.726,
- "n2": 2.554,
- "n3": 2.449,
- "n4": 2.39,
- "n5": 2.153,
- "n6": 2.289,
- "n7": 1.235
-}
\ No newline at end of file
diff --git a/styles/crayon-book/demo/voices_v2/n1.wav b/styles/crayon-book/demo/voices_v2/n1.wav
deleted file mode 100644
index c98dd03..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n1.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n2.wav b/styles/crayon-book/demo/voices_v2/n2.wav
deleted file mode 100644
index 536ee9f..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n2.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n3.wav b/styles/crayon-book/demo/voices_v2/n3.wav
deleted file mode 100644
index e5b8ed1..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n3.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n4.wav b/styles/crayon-book/demo/voices_v2/n4.wav
deleted file mode 100644
index 469d443..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n4.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n5.wav b/styles/crayon-book/demo/voices_v2/n5.wav
deleted file mode 100644
index 88a5eec..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n5.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n6.wav b/styles/crayon-book/demo/voices_v2/n6.wav
deleted file mode 100644
index d3063e2..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n6.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/n7.wav b/styles/crayon-book/demo/voices_v2/n7.wav
deleted file mode 100644
index 8e8d1ff..0000000
Binary files a/styles/crayon-book/demo/voices_v2/n7.wav and /dev/null differ
diff --git a/styles/crayon-book/demo/voices_v2/words.json b/styles/crayon-book/demo/voices_v2/words.json
deleted file mode 100644
index 8d6bac2..0000000
--- a/styles/crayon-book/demo/voices_v2/words.json
+++ /dev/null
@@ -1,246 +0,0 @@
-{
-"n1": [
-[
-"The",
--0.6,
-0.14
-],
-[
-"moon",
-0.14,
-0.32
-],
-[
-"could",
-0.32,
-0.6
-],
-[
-"not",
-0.6,
-0.84
-],
-[
-"sleep.",
-0.84,
-1.24
-]
-],
-"n2": [
-[
-"It",
--0.6,
-0.1
-],
-[
-"tossed",
-0.1,
-0.36
-],
-[
-"and",
-0.36,
-0.7
-],
-[
-"it",
-0.7,
-0.82
-],
-[
-"turned",
-0.82,
-1.12
-],
-[
-"and",
-1.12,
-1.44
-],
-[
-"it",
-1.44,
-1.54
-],
-[
-"counted",
-1.54,
-1.76
-],
-[
-"sheep.",
-1.76,
-2.14
-]
-],
-"n3": [
-[
-"Down",
--0.6,
-0.18
-],
-[
-"below,",
-0.18,
-0.48
-],
-[
-"someone",
-0.78,
-1.04
-],
-[
-"else",
-1.04,
-1.32
-],
-[
-"was",
-1.32,
-1.5
-],
-[
-"awake",
-1.5,
-1.74
-],
-[
-"too.",
-1.74,
-2.14
-]
-],
-"n4": [
-[
-"So",
--0.6,
-0.16
-],
-[
-"she",
-0.16,
-0.32
-],
-[
-"climbed",
-0.32,
-0.56
-],
-[
-"up",
-0.56,
-0.86
-],
-[
-"up",
-0.86,
-1.18
-],
-[
-"up",
-1.18,
-1.36
-],
-[
-"onto",
-1.36,
-1.7
-],
-[
-"the",
-1.7,
-1.82
-],
-[
-"roof.",
-1.82,
-1.98
-]
-],
-"n5": [
-[
-"and",
--0.6,
-0.16
-],
-[
-"sang",
-0.16,
-0.38
-],
-[
-"the",
-0.38,
-0.6
-],
-[
-"softest",
-0.6,
-1.08
-],
-[
-"song",
-1.08,
-1.36
-],
-[
-"she",
-1.36,
-1.64
-],
-[
-"knew.",
-1.64,
-1.84
-]
-],
-"n6": [
-[
-"And",
--0.6,
-0.2
-],
-[
-"at",
-0.2,
-0.28
-],
-[
-"last,",
-0.28,
-0.52
-],
-[
-"the",
-0.9,
-0.92
-],
-[
-"moon",
-0.92,
-1.1
-],
-[
-"fell",
-1.1,
-1.38
-],
-[
-"asleep.",
-1.38,
-1.8
-]
-],
-"n7": [
-[
-"Night",
--0.6,
-0.34
-],
-[
-"Night",
-0.34,
-0.7
-]
-]
-}
\ No newline at end of file
diff --git a/styles/paper-lantern/demo/render/dbg.mjs b/styles/paper-lantern/demo/render/dbg.mjs
deleted file mode 100644
index 2cd2bc1..0000000
--- a/styles/paper-lantern/demo/render/dbg.mjs
+++ /dev/null
@@ -1,12 +0,0 @@
-import fs from 'fs';
-import path from 'path';
-import { openPage, closeServer, ROOT } from './page.mjs';
-const { browser, page } = await openPage();
-const r = await page.evaluate(async () => {
- const P = await import(new URL('src/paper.js', location.href).href); const T = await import(new URL('src/shots/s10_pass.js', location.href).href);
- const c = P.finish(P.paint(.11 * 1.45 * 2, .13, x => T.carriage(x, 2, .11 * 1.45, .05 * 1.45, '#1f5140', false), 2000));
- return c.toDataURL('image/png');
-});
-fs.mkdirSync(path.join(ROOT, 'stills/dbg'), { recursive: true });
-fs.writeFileSync(path.join(ROOT, 'stills/dbg/carriage.png'), Buffer.from(r.split(',')[1], 'base64'));
-await browser.close(); closeServer();
diff --git a/styles/pictogram-motion/demo/err.txt b/styles/pictogram-motion/demo/err.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/styles/ukiyoe/demo/music/score_v2.json b/styles/ukiyoe/demo/music/score_v2.json
deleted file mode 100644
index 9807ca3..0000000
--- a/styles/ukiyoe/demo/music/score_v2.json
+++ /dev/null
@@ -1,296 +0,0 @@
-{
- "dur": 42.0,
- "sr": 48000,
- "peak": 0.89,
- "ma_silent_28_46_to_30_2": true,
- "impact": 28.36,
- "cues": [
- {
- "cue": "C1 印刷",
- "t0": 0,
- "t1": 2.9,
- "rms_db": -34.099998474121094,
- "peak": 0.406,
- "centroid_hz": 4853.0
- },
- {
- "cue": "C2 序",
- "t0": 2.9,
- "t1": 10.5,
- "rms_db": -22.100000381469727,
- "peak": 0.385,
- "centroid_hz": 1640.0
- },
- {
- "cue": "C3 雨",
- "t0": 10.5,
- "t1": 17.3,
- "rms_db": -27.0,
- "peak": 0.455,
- "centroid_hz": 2085.0
- },
- {
- "cue": "C4 破",
- "t0": 17.3,
- "t1": 22.9,
- "rms_db": -31.799999237060547,
- "peak": 0.396,
- "centroid_hz": 1990.0
- },
- {
- "cue": "C5 急",
- "t0": 22.9,
- "t1": 28.4,
- "rms_db": -18.299999237060547,
- "peak": 0.89,
- "centroid_hz": 894.0
- },
- {
- "cue": "C6 間",
- "t0": 28.4,
- "t1": 30.2,
- "rms_db": -29.700000762939453,
- "peak": 0.58,
- "centroid_hz": 968.0
- },
- {
- "cue": "C7 回响",
- "t0": 30.2,
- "t1": 36.8,
- "rms_db": -21.299999237060547,
- "peak": 0.55,
- "centroid_hz": 1283.0
- },
- {
- "cue": "C8 尾",
- "t0": 36.8,
- "t1": 42.0,
- "rms_db": -25.799999237060547,
- "peak": 0.439,
- "centroid_hz": 2209.0
- }
- ],
- "voice_windows": [
- {
- "line": "L1",
- "rms_db": -28.100000381469727,
- "mid_1_4k_db": -35.8
- },
- {
- "line": "L2",
- "rms_db": -39.599998474121094,
- "mid_1_4k_db": -43.6
- },
- {
- "line": "L3",
- "rms_db": -33.099998474121094,
- "mid_1_4k_db": -41.3
- },
- {
- "line": "L4",
- "rms_db": -26.200000762939453,
- "mid_1_4k_db": -53.8
- },
- {
- "line": "L5",
- "rms_db": -24.600000381469727,
- "mid_1_4k_db": -36.7
- }
- ],
- "onsets": {
- "0.35": {
- "err_ms": 0.3,
- "peak": 0.284
- },
- "1.05": {
- "err_ms": 0.1,
- "peak": 0.311
- },
- "1.7": {
- "err_ms": 0.2,
- "peak": 0.339
- },
- "2.3": {
- "err_ms": -0.0,
- "peak": 0.363
- },
- "30.2": {
- "err_ms": 0.4,
- "peak": 0.319
- },
- "30.7": {
- "err_ms": 0.8,
- "peak": 0.363
- },
- "31.2": {
- "err_ms": -2.0,
- "peak": 0.411
- },
- "31.7": {
- "err_ms": 0.7,
- "peak": 0.482
- },
- "28.36": {
- "err_ms": -50.0,
- "peak": 0.83
- }
- },
- "events": [
- [
- 0.35,
- "hyoshigi",
- "拍子木 1(第1版)"
- ],
- [
- 1.05,
- "hyoshigi",
- "拍子木 2(第2版)"
- ],
- [
- 1.7,
- "hyoshigi",
- "拍子木 3(第3版)"
- ],
- [
- 2.3,
- "hyoshigi",
- "拍子木 4(第4版)"
- ],
- [
- 2.9,
- "shamisen",
- "片名:三味线和弦"
- ],
- [
- 3.05,
- "shakuhachi",
- "尺八:动机 A4"
- ],
- [
- 6.35,
- "shakuhachi",
- "尺八:低音 ro 长音(让位旁白)"
- ],
- [
- 10.1,
- "shamisen",
- "印章:三味线 チン"
- ],
- [
- 11.5,
- "shamisen",
- "三味线慢脉动 72BPM"
- ],
- [
- 16.0,
- "shamisen",
- "印章:三味线"
- ],
- [
- 14.45,
- "shakuhachi",
- "尺八应答"
- ],
- [
- 17.3,
- "shamisen",
- "三味线固定音型 96BPM"
- ],
- [
- 17.925,
- "taiko",
- "締太鼓"
- ],
- [
- 21.95,
- "shamisen",
- "印章:三味线"
- ],
- [
- 22.32,
- "shamisen",
- "急平移:上行快速琶音"
- ],
- [
- 23.2,
- "taiko",
- "大太鼓心跳起(渐快→滚奏)"
- ],
- [
- 27.0,
- "taiko",
- "滚奏最密 27.0–27.7"
- ],
- [
- 25.4,
- "shamisen",
- "三味线震音渐强"
- ],
- [
- 27.25,
- "shakuhachi",
- "尺八高音嘶鸣 muraiki"
- ],
- [
- 28.36,
- "taiko",
- "冲击:大太鼓 + 三味线和弦 + 拍子木"
- ],
- [
- 30.2,
- "taiko",
- "太鼓第1版"
- ],
- [
- 30.7,
- "taiko",
- "太鼓第2版"
- ],
- [
- 31.2,
- "taiko",
- "太鼓第3版"
- ],
- [
- 31.7,
- "taiko",
- "太鼓第4版"
- ],
- [
- 32.1,
- "shamisen",
- "三味线轻分解和弦"
- ],
- [
- 32.05,
- "shakuhachi",
- "尺八:动机回响"
- ],
- [
- 35.3,
- "shakuhachi",
- "尺八:落在主音 D"
- ],
- [
- 35.1,
- "shamisen",
- "摘斗笠:三味线泛音"
- ],
- [
- 36.3,
- "shamisen",
- "终印:三味线终止和弦 + 太鼓 + 拍子木"
- ],
- [
- 37.0,
- "shakuhachi",
- "尺八最后长音"
- ],
- [
- 38.4,
- "shamisen",
- "三味线末音 sawari 长余振"
- ]
- ],
- "notes": "都节音阶 D Eb G A Bb;开场动机 A4–Bb4–A4(meri);C7 回响落在 D4。拍子木=合成硬木共振+claves+woodblock;太鼓=合成鼓皮(120→58Hz)+gran_cassa+toms low_mallet+frame_drum large;尺八=recorder62%+flute38% 采样→除以平滑包络去幅度颤动、f0 跟踪反向变速去音高颤动、滑入/meri/kari 变速、1–4k 气声。"
-}
\ No newline at end of file
diff --git a/styles/ukiyoe/demo/music/score_v2.py b/styles/ukiyoe/demo/music/score_v2.py
deleted file mode 100644
index 008ed4f..0000000
--- a/styles/ukiyoe/demo/music/score_v2.py
+++ /dev/null
@@ -1,262 +0,0 @@
-"""Toward the Mountain — 原创配乐(序・破・急)
-三味线(pluck 物理建模,sawari)+ 尺八(recorder/flute 采样:去颤音、气声、滑入、meri/kari)
-+ 太鼓(大鼓/通鼓/框鼓采样 + 合成鼓皮)+ 拍子木(木块/响棒采样 + 合成硬木共振)
-运行:.venv/bin/python styles/ukiyoe/demo/music/score.py → music/score.wav, stems/, score.json
-"""
-import sys, os, json
-ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))
-sys.path.insert(0, ROOT)
-import numpy as np, soundfile as sf
-from scipy.signal import butter, sosfilt
-from core.audio import sampler as S, pluck as P
-from core.audio.sfx import SR, add
-
-HERE = os.path.dirname(os.path.abspath(__file__))
-DUR = 42.0
-N = int(DUR * SR)
-rng = np.random.default_rng(1703)
-S.seed(17)
-def bpf(x, lo, hi, o=2): return sosfilt(butter(o, [lo, hi], 'band', fs=SR, output='sos'), x)
-def lpf(x, f, o=2): return sosfilt(butter(o, f, 'low', fs=SR, output='sos'), x)
-def hpf(x, f, o=2): return sosfilt(butter(o, f, 'high', fs=SR, output='sos'), x)
-def st(): return np.zeros((N, 2), np.float32)
-stems = {k: st() for k in ['shamisen', 'shakuhachi', 'taiko', 'hyoshigi', 'other']}
-EVENTS = [] # (t, stem, 说明)
-def mark(t, k, d): EVENTS.append((round(t, 3), k, d))
-
-# ——————————————— 拍子木(两块硬木互击)———————————————
-def hyoshigi(v=1.0):
- L = int(.5 * SR); t = np.arange(L) / SR
- y = np.zeros(L)
- for f, a, tau in [(1180, 1., .05), (2460, .7, .035), (3870, .45, .022), (5300, .25, .012), (760, .35, .07)]:
- y += a * np.sin(2 * np.pi * f * t + rng.random() * 6) * np.exp(-t / tau)
- cl = rng.standard_normal(L) * np.exp(-t / .0018); y += 1.6 * bpf(cl, 1500, 9000)
- y /= np.abs(y).max()
- s1 = S.hit('world_perc', 'claves', .9); s2 = S.hit('woodblock', 'a', .9)
- out = np.zeros(L); out[:min(L, len(s1))] += s1[:L] / (np.abs(s1).max() + 1e-9) * .8; out[:min(L, len(s2))] += s2[:L] / (np.abs(s2).max() + 1e-9) * .45
- out += y * .9
- # 两块木头几乎同时相击:3 ms 后的第二个瞬态
- d = int(.003 * SR); out[d:] += .35 * out[:-d]
- return (out / np.abs(out).max() * .85 * v).astype(np.float32)
-
-# ——————————————— 太鼓 ———————————————
-def odaiko(v=1.0, big=False):
- L = int(2.4 * SR); t = np.arange(L) / SR
- f = 58 + 62 * np.exp(-t / .045) # 鼓皮被击后音高下滑
- ph = 2 * np.pi * np.cumsum(f) / SR
- body = np.sin(ph) * np.exp(-t / (.55 if big else .42)) + .35 * np.sin(1.59 * ph + 1) * np.exp(-t / .22) + .18 * np.sin(2.14 * ph) * np.exp(-t / .12)
- don = bpf(rng.standard_normal(L), 90, 900) * np.exp(-t / .02) * .8 # 击面"咚"
- stick = bpf(rng.standard_normal(L), 1200, 5000) * np.exp(-t / .004) * .25 # 鼓槌
- syn = body + don + stick
- syn /= np.abs(syn).max()
- out = syn * .85
- for inst, var, g in [('gran_cassa', 'hit', .55), ('toms', 'low_mallet', .35), ('frame_drum', 'large', .3)]:
- s = S.hit(inst, var, min(1, .55 + .45 * v)); s = s[:L] / (np.abs(s).max() + 1e-9)
- out[:len(s)] += s * g
- out = lpf(out, 3500)
- return (out / np.abs(out).max() * v).astype(np.float32)
-def shime(v=.6):
- L = int(.6 * SR); t = np.arange(L) / SR
- f = 390 + 140 * np.exp(-t / .01); ph = 2 * np.pi * np.cumsum(f) / SR
- y = np.sin(ph) * np.exp(-t / .07) + .5 * bpf(rng.standard_normal(L), 800, 4000) * np.exp(-t / .006)
- s = S.hit('frame_drum', 'small_muted', .7); s = s[:L] / (np.abs(s).max() + 1e-9)
- y = y / np.abs(y).max() * .7; y[:len(s)] += s * .5
- return (y / np.abs(y).max() * v).astype(np.float32)
-
-# ——————————————— 三味线 ———————————————
-def sam(p, v=.7, dur=None, **kw):
- kw.setdefault('buzz', .7)
- return P.pluck('shamisen', p, dur, v, **kw)
-
-# ——————————————— 尺八(采样 recorder+flute → 去颤音、滑音、气声)———————————————
-def _f0track(y, f):
- hop, Nw = 480, 2048; out = []
- for s in range(0, max(1, len(y) - Nw), hop):
- fr = y[s:s + Nw] * np.hanning(Nw); sp = np.abs(np.fft.rfft(fr, 8 * Nw)); fq = np.fft.rfftfreq(8 * Nw, 1 / SR)
- m = (fq > f * .85) & (fq < f * 1.18); out.append(fq[m][np.argmax(sp[m])] if sp[m].max() > 1e-6 else f)
- return np.array(out), hop
-def shaku(p, dur, v=.7, slide=-1.5, fall=0.0, kari=0.0, swell=.5, breath=1.0, rel=.35):
- """p: 实际音高;slide: 起音从下方几个半音滑入(0=不滑);fall: 句尾 meri 下滑半音(负);kari: 句尾上扬(正)
- swell: 音中段渐强程度;breath: 气声比例"""
- m = S.midi(p); f = 440 * 2 ** ((m - 69) / 12)
- ext = dur + rel + .8
- a = S.note('recorder', max(m, S.midi('F4') - 3), ext, .7, release=.2)
- b = S.note('flute', max(m, S.midi('C4')), ext, .6, release=.2)
- n = min(len(a), len(b)); y = .62 * a[:n] / (np.abs(a).max() + 1e-9) + .38 * b[:n] / (np.abs(b).max() + 1e-9)
- y = y.astype(np.float64)
- # 1) 去掉幅度颤动:除以平滑包络
- w = int(.06 * SR); e = np.sqrt(np.convolve(y ** 2, np.ones(w) / w, 'same')) + 1e-4
- e = np.convolve(e, np.ones(w) / w, 'same'); y = y / e
- y[:int(.03 * SR)] *= np.linspace(0, 1, int(.03 * SR))
- # 2) 去掉音高颤动 + 施加滑音:变速重采样
- tr, hop = _f0track(y, f); dev = 12 * np.log2(tr / np.median(tr[3:])) # 半音
- dev = np.clip(dev, -.6, .6)
- tt = np.arange(n) / SR; devs = np.interp(tt, np.arange(len(dev)) * hop / SR + 1024 / SR, dev)
- L = int((dur + rel) * SR); to = np.arange(L) / SR
- bend = np.zeros(L)
- if slide: sl = .16; bend += np.where(to < sl, slide * (1 - np.sin(np.clip(to / sl, 0, 1) * np.pi / 2)), 0)
- if fall: k = np.clip((to - (dur - .45)) / .5, 0, 1); bend += fall * k * k
- if kari: k = np.clip((to - (dur - .3)) / .3, 0, 1); bend += kari * np.sin(k * np.pi / 2)
- dv = np.interp(to + .05, tt, devs)
- phase = .05 * SR + np.concatenate([[0], np.cumsum(2 ** ((bend[:-1] - dv[:-1]) / 12))])
- phase = np.minimum(phase, n - 2)
- z = np.interp(phase, np.arange(n), y)
- # 3) 自己的包络:气先出、音后到;中段渐强再回落(尺八式呼吸)
- at = .12; envl = np.clip(to / at, 0, 1) ** 1.6
- mid = 1 + swell * np.sin(np.clip(to / max(dur, .1), 0, 1) * np.pi) ** 1.5 * .8
- relk = np.clip((to - dur) / rel, 0, 1); envl = envl * mid * (1 - relk) ** 2
- z = z * envl
- # 暗一点、中空一点
- z = lpf(z, 3200) * .8 + bpf(z, 900, 1600) * .5
- # 4) 气声:1–4 kHz 带通噪声,起音更强(muraiki)
- nz = bpf(rng.standard_normal(L), 1000, 4000, 3)
- be = .22 * envl + .9 * np.exp(-np.clip(to, 0, None) / .07) * np.clip(to / .012, 0, 1)
- z = z / (np.abs(z).max() + 1e-9) + breath * .5 * nz / (np.abs(nz).max() + 1e-9) * be
- z[-min(len(z), 480):] *= np.linspace(1, 0, min(len(z), 480))
- return (z / (np.abs(z).max() + 1e-9) * v).astype(np.float32)
-
-def put(k, x, t, g=1.0, pan=0.0, note=None):
- add(stems[k], x, t, g, pan)
- if note: mark(t, k, note)
-
-# ================= C1 印刷:拍子木 =================
-for i, t in enumerate([.35, 1.05, 1.70, 2.30]):
- put('hyoshigi', hyoshigi(.8 + .07 * i), t, 1.0, (-.25, .2, -.1, .15)[i], f'拍子木 {i+1}(第{i+1}版)')
-
-# ================= C2 序 2.9–10.5 =================
-put('shamisen', P.strum('shamisen', ['D3', 'A3', 'D4'], None, .85, spread=.018, buzz=.8, t60=2.2), 2.9, 1.1, -.15, '片名:三味线和弦')
-# 尺八开场动机 M:A4(滑入)— Bb4 — A4(meri 落)… G4
-put('shakuhachi', shaku('A4', 1.55, .75, slide=-2, swell=.6), 3.05, 1, .1, '尺八:动机 A4')
-put('shakuhachi', shaku('Bb4', .42, .6, slide=0, swell=.1, breath=.7), 4.72, 1, .1)
-put('shakuhachi', shaku('A4', .95, .66, slide=0, fall=-1.2, swell=.3), 5.12, 1, .1)
-put('shamisen', sam('A3', .45), 4.72, .7, -.2)
-# 旁白 L1 6.0–9.5:只留一个低音长音 + 零星三味线
-put('shakuhachi', shaku('D4', 2.9, .42, slide=-1, swell=.8, breath=.8, rel=.6), 6.35, 1, .1, '尺八:低音 ro 长音(让位旁白)')
-put('shamisen', sam('D3', .4), 7.6, .6, -.2)
-put('shamisen', sam('D5', .75, t60=.8, buzz=.5), 10.1, .9, .15, '印章:三味线 チン')
-
-# ================= C3 雨 72 BPM =================
-bt = 60 / 72
-beats = [11.5 + i * bt for i in range(7)]
-for i, b in enumerate(beats):
- quiet = 12.2 < b < 14.3
- put('shamisen', sam('D3' if i % 2 == 0 else 'A2', (.5 if quiet else .66)), b, .8, -.15, '三味线慢脉动 72BPM' if i == 0 else None)
- if b + bt / 2 < 16.9:
- put('shamisen', sam('A3' if i % 3 else 'D4', .3 if quiet else .38, buzz=.4), b + bt / 2, .6, .1) # すくい 轻上拨
-put('shamisen', sam('Eb5', .72, t60=.8, buzz=.5), 16.0, .9, .15, '印章:三味线')
-put('shakuhachi', shaku('G4', .7, .55, slide=-1.5, swell=.3), 14.45, 1, .05, '尺八应答')
-put('shakuhachi', shaku('A4', .95, .58, slide=0, kari=.8, swell=.4), 15.15, 1, .05)
-
-# ================= C4 破 96 BPM =================
-bt = 60 / 96; e8 = bt / 2
-pat = ['D4', 'A3', 'D4', 'Eb4', 'D4', 'A3', 'G3', 'A3']
-t = 17.3; i = 0
-while t < 22.25:
- quiet = 18.0 < t < 20.7
- v = (.44 if quiet else .56) * (1.0 if i % 2 == 0 else .75)
- put('shamisen', sam(pat[i % 8], v, buzz=.55), t, .75, -.1 + .2 * (i % 2), '三味线固定音型 96BPM' if i == 0 else None)
- if i % 4 == 2: put('taiko', shime(.42 if quiet else .55), t, .9, .3, '締太鼓' if i == 2 else None)
- if i % 8 == 7: put('taiko', shime(.3), t + e8 / 2, .9, .3)
- t += e8; i += 1
-put('shamisen', sam('D5', .75, t60=.8, buzz=.5), 21.95, .9, .15, '印章:三味线')
-for k, p in enumerate(['D3', 'A3', 'D4', 'Eb4', 'G4', 'A4', 'Bb4', 'D5']):
- put('shamisen', sam(p, .5 + k * .04, buzz=.6), 22.32 + k * .06, .8, -.3 + k * .08, '急平移:上行快速琶音' if k == 0 else None)
-
-# ================= C5 急 =================
-ts = []; t = 23.2; gap = .9
-while t < 27.0:
- ts.append(t); gap = max(.13, gap * .84); t += gap
-t = ts[-1] + .12
-while t < 27.7:
- ts.append(t); t += .1
-t = 27.7
-while t < 28.3:
- ts.append(t); t += .075
-for j, t in enumerate(ts):
- prog = (t - 23.2) / 5.1
- v = .55 + .4 * prog
- if 23.5 < t < 25.4: v *= .8
- put('taiko', odaiko(min(1, v)), t, .85, (rng.random() - .5) * .3, '大太鼓心跳起(渐快→滚奏)' if j == 0 else None)
-mark(27.0, 'taiko', '滚奏最密 27.0–27.7')
-# 三味线震音 25.4 起渐强
-tr = P.pluck('shamisen', 'D4', 2.9, .75, trem=13, buzz=.8, t60=1.0)
-g = np.linspace(.15, 1, len(tr)) ** 1.5; tr = (tr * g).astype(np.float32)
-put('shamisen', tr, 25.4, .7, -.25, '三味线震音渐强')
-tr2 = P.pluck('shamisen', 'A4', 2.0, .7, trem=14, buzz=.8, t60=1.0); tr2 = (tr2 * np.linspace(.1, 1, len(tr2)) ** 2).astype(np.float32)
-put('shamisen', tr2, 26.3, .55, .25)
-# 尺八高音嘶鸣(muraiki)
-put('shakuhachi', shaku('D6', .55, .9, slide=-2, kari=.7, swell=.4, breath=2.2, rel=.12), 27.25, .62, .1, '尺八高音嘶鸣 muraiki')
-# 冲击 28.36
-IMP = 28.36
-put('taiko', odaiko(1.0, big=True), IMP, 1.5, 0, '冲击:大太鼓 + 三味线和弦 + 拍子木')
-put('taiko', odaiko(.9, big=True), IMP + .004, .8, -.3)
-put('shamisen', P.strum('shamisen', ['D3', 'A3', 'D4', 'A4'], .3, 1.0, spread=.008, buzz=1.0), IMP, 1.0, 0)
-put('hyoshigi', hyoshigi(.9), IMP, .8, .2)
-
-# ================= C7 回响 =================
-for i, t in enumerate([30.2, 30.7, 31.2, 31.7]):
- put('taiko', odaiko(.72 + .09 * i, big=True), t, 1.0, (-.1, .1, -.05, .05)[i], f'太鼓第{i+1}版')
-put('shamisen', P.strum('shamisen', ['D3', 'A3', 'D4'], None, .5, spread=.12, buzz=.6, t60=1.8), 32.1, .5, -.2, '三味线轻分解和弦')
-# 尺八回到动机,落在主音 D
-put('shakuhachi', shaku('A4', 1.3, .55, slide=-2, swell=.5), 32.05, .62, .1, '尺八:动机回响')
-put('shakuhachi', shaku('Bb4', .4, .46, slide=0, swell=.1, breath=.7), 33.5, .62, .1)
-put('shakuhachi', shaku('A4', .75, .5, slide=0, fall=-.8, swell=.3), 33.9, .62, .1)
-put('shakuhachi', shaku('G4', .55, .5, slide=0, swell=.2), 34.75, .75, .1)
-put('shakuhachi', shaku('D4', 1.05, .55, slide=-1, swell=.5, rel=.4), 35.3, 1, .1, '尺八:落在主音 D')
-put('shamisen', sam('A4', .38, harmonic=True), 35.1, .7, .3, '摘斗笠:三味线泛音')
-put('shamisen', P.strum('shamisen', ['D3', 'A3', 'D4'], None, .9, spread=.02, buzz=.85, t60=2.4), 36.3, 1.1, 0, '终印:三味线终止和弦 + 太鼓 + 拍子木')
-put('taiko', odaiko(.85, big=True), 36.3, .9, 0)
-put('hyoshigi', hyoshigi(.7), 36.3, .7, .25)
-
-# ================= C8 尾 =================
-put('shakuhachi', shaku('D5', 3.6, .5, slide=-2, fall=-1.0, swell=.7, breath=1.1, rel=.9), 37.0, 1, .1, '尺八最后长音')
-put('shamisen', sam('D3', .7, t60=4.2, buzz=.9), 38.4, 1.0, -.1, '三味线末音 sawari 长余振')
-
-# ================= 混响、静音、合成 =================
-wet = {'shamisen': (.45, .2), 'shakuhachi': (.6, .3), 'taiko': (.65, .22), 'hyoshigi': (.35, .12), 'other': (.5, .2)}
-for k, (sz, mx) in wet.items():
- if np.abs(stems[k]).max() > 0: stems[k] = S.room(stems[k], size=sz, mix=mx).astype(np.float32)
-GAIN = {'shamisen': 1.0, 'shakuhachi': .8, 'taiko': .95, 'hyoshigi': .85, 'other': 1.0}
-MA0, MA1 = 28.40, 30.2
-fade = int(.06 * SR); a0 = int(MA0 * SR); a1 = int(MA1 * SR)
-tail = int(42.0 * SR) - int(.2 * SR)
-for k in stems:
- x = stems[k] * GAIN[k]
- x[a0:a0 + fade] *= np.linspace(1, 0, fade)[:, None]
- x[a0 + fade:a1] = 0
- x[a1 - 1] = 0
- # 42.0 前归零
- x[tail:] *= np.linspace(1, 0, N - tail)[:, None]
- stems[k] = x.astype(np.float32)
-mix = sum(stems.values())
-pk = np.abs(mix).max(); sc = .89 / pk
-mix *= sc
-for k in stems: stems[k] *= sc
-os.makedirs(os.path.join(HERE, 'stems'), exist_ok=True)
-sf.write(os.path.join(HERE, 'score.wav'), mix.astype(np.float32), SR, subtype='FLOAT')
-for k, x in stems.items(): sf.write(os.path.join(HERE, 'stems', k + '.wav'), x, SR, subtype='FLOAT')
-
-# ================= 自检 =================
-mono = mix.mean(1)
-def rms_db(a, b):
- s = mono[int(a * SR):int(b * SR)]; r = np.sqrt(np.mean(s ** 2)) + 1e-12; return round(20 * np.log10(r), 1)
-def cent(a, b):
- s = mono[int(a * SR):int(b * SR)]
- if np.abs(s).max() == 0: return 0
- sp = np.abs(np.fft.rfft(s * np.hanning(len(s)))); f = np.fft.rfftfreq(len(s), 1 / SR); return round(float((sp * f).sum() / sp.sum()), 0)
-CUES = [('C1 印刷', 0, 2.9), ('C2 序', 2.9, 10.5), ('C3 雨', 10.5, 17.3), ('C4 破', 17.3, 22.9), ('C5 急', 22.9, 28.4), ('C6 間', 28.4, 30.2), ('C7 回响', 30.2, 36.8), ('C8 尾', 36.8, 42.0)]
-table = [dict(cue=n, t0=a, t1=b, rms_db=rms_db(a, b), peak=round(float(np.abs(mix[int(a * SR):int(b * SR)]).max()), 3), centroid_hz=cent(a, b)) for n, a, b in CUES]
-VO = [('L1', 6.0, 9.5), ('L2', 12.3, 14.2), ('L3', 18.0, 20.6), ('L4', 23.5, 25.4), ('L5', 32.4, 35.1)]
-vo = [dict(line=n, rms_db=rms_db(a, b), mid_1_4k_db=round(20 * np.log10(np.sqrt(np.mean(bpf(mono[int(a * SR):int(b * SR)], 1000, 4000) ** 2)) + 1e-12), 1)) for n, a, b in VO]
-silent = bool(np.all(mix[int((MA0 + .061) * SR):int(MA1 * SR)] == 0))
-def onset_err(t, win=.05):
- s = int((t - win) * SR); seg = np.abs(mono[s:s + int(2 * win * SR)])
- thr = .3 * seg.max(); i = int(np.argmax(seg > thr)); return round((s + i) / SR * 1000 - t * 1000, 1), round(float(seg.max()), 3)
-ons = {str(t): dict(zip(['err_ms', 'peak'], onset_err(t))) for t in [.35, 1.05, 1.70, 2.30, 30.2, 30.7, 31.2, 31.7, IMP]}
-report = dict(dur=len(mix) / SR, sr=SR, peak=round(float(np.abs(mix).max()), 3), ma_silent_28_46_to_30_2=silent,
- impact=IMP, cues=table, voice_windows=vo, onsets=ons, events=EVENTS,
- notes='都节音阶 D Eb G A Bb;开场动机 A4–Bb4–A4(meri);C7 回响落在 D4。拍子木=合成硬木共振+claves+woodblock;太鼓=合成鼓皮(120→58Hz)+gran_cassa+toms low_mallet+frame_drum large;尺八=recorder62%+flute38% 采样→除以平滑包络去幅度颤动、f0 跟踪反向变速去音高颤动、滑入/meri/kari 变速、1–4k 气声。')
-json.dump(report, open(os.path.join(HERE, 'score.json'), 'w'), ensure_ascii=False, indent=1, default=float)
-print(json.dumps({k: report[k] for k in ['dur', 'peak', 'ma_silent_28_46_to_30_2', 'onsets']}, ensure_ascii=False))
-for r in table: print(r)
-for r in vo: print(r)
diff --git a/styles/watercolor/demo/chk_sheet.png b/styles/watercolor/demo/chk_sheet.png
deleted file mode 100644
index ce90fd1..0000000
Binary files a/styles/watercolor/demo/chk_sheet.png and /dev/null differ
diff --git a/styles/watercolor/demo/crop.png b/styles/watercolor/demo/crop.png
deleted file mode 100644
index 14d3b95..0000000
Binary files a/styles/watercolor/demo/crop.png and /dev/null differ
diff --git a/styles/watercolor/demo/s1.jpg b/styles/watercolor/demo/s1.jpg
deleted file mode 100644
index babfef8..0000000
Binary files a/styles/watercolor/demo/s1.jpg and /dev/null differ
diff --git a/styles/watercolor/demo/s2.jpg b/styles/watercolor/demo/s2.jpg
deleted file mode 100644
index fd85d66..0000000
Binary files a/styles/watercolor/demo/s2.jpg and /dev/null differ
diff --git a/styles/watercolor/demo/s3.jpg b/styles/watercolor/demo/s3.jpg
deleted file mode 100644
index d41bb15..0000000
Binary files a/styles/watercolor/demo/s3.jpg and /dev/null differ
diff --git a/styles/watercolor/demo/s4.jpg b/styles/watercolor/demo/s4.jpg
deleted file mode 100644
index 476b299..0000000
Binary files a/styles/watercolor/demo/s4.jpg and /dev/null differ
diff --git a/styles/watercolor/demo/tts/test.py b/styles/watercolor/demo/tts/test.py
deleted file mode 100644
index 745168c..0000000
--- a/styles/watercolor/demo/tts/test.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 声线试听(选定 af_heart)
-import soundfile as sf, time, os
-from kokoro_onnx import Kokoro
-HERE = os.path.dirname(os.path.abspath(__file__)); os.chdir(HERE)
-CORE = os.path.join(HERE, '..', '..', '..', '..', 'core', 'tts')
-k = Kokoro(os.path.join(CORE, "kokoro-v1.0.onnx"), os.path.join(CORE, "voices-v1.0.bin"))
-txt = "Australia begins with a single line. At its heart, the red centre, where less than two hundred and fifty millimetres of rain falls in a year."
-for v in ["af_heart", "bf_emma", "bm_george", "af_bella"]:
- t=time.time(); s, sr = k.create(txt, voice=v, speed=0.95, lang="en-us" if v[0]=='a' else "en-gb")
- sf.write(f"test_{v}.wav", s, sr); print(v, sr, len(s)/sr, round(time.time()-t,1))
diff --git a/styles/watercolor/demo/tts/test_af_bella.wav b/styles/watercolor/demo/tts/test_af_bella.wav
deleted file mode 100644
index 67fe418..0000000
Binary files a/styles/watercolor/demo/tts/test_af_bella.wav and /dev/null differ
diff --git a/styles/watercolor/demo/tts/test_af_heart.wav b/styles/watercolor/demo/tts/test_af_heart.wav
deleted file mode 100644
index 5c842a5..0000000
Binary files a/styles/watercolor/demo/tts/test_af_heart.wav and /dev/null differ
diff --git a/styles/watercolor/demo/tts/test_bf_emma.wav b/styles/watercolor/demo/tts/test_bf_emma.wav
deleted file mode 100644
index 636e4a3..0000000
Binary files a/styles/watercolor/demo/tts/test_bf_emma.wav and /dev/null differ
diff --git a/styles/watercolor/demo/tts/test_bm_george.wav b/styles/watercolor/demo/tts/test_bm_george.wav
deleted file mode 100644
index 17ff5df..0000000
Binary files a/styles/watercolor/demo/tts/test_bm_george.wav and /dev/null differ
diff --git a/styles/whiteboard/TREATMENT.md b/styles/whiteboard/TREATMENT.md
index a351748..aeeefe1 100644
--- a/styles/whiteboard/TREATMENT.md
+++ b/styles/whiteboard/TREATMENT.md
@@ -1,7 +1,7 @@
# TREATMENT · Whiteboard Explainer v2 ·《Einstein in Your Pocket》
> 111 秒 · 英文旁白(Kokoro bm_george,en-gb)· 1920×1080 / 24fps · 全片一块白板,**画面里没有手**
-> 2026-09-26 起为本风格正式 demo;旧版《Why Bread Rises》移到 `视频测试/Video Trail/opuscar-old-demos/whiteboard/`。
+> 2026-09-26 起为本风格正式 demo(替换了旧版《Why Bread Rises》)。
## 1. 对标(只学语法)