# 從空白 Timeline 到一首完成的 VOCALOID 歌曲 ## 把作曲、調教、渲染、混音、Mastering 與可驗證交付,做成 Agent-Native 的 VOCALOID3 MCP - **專案 checkpoint:** 2026-07-18;matching VSQX delivery 於 2026-07-19 補齊 - **實作:** TypeScript、Model Context Protocol、native Win32 helpers、VOCALOID3 Editor、FluidSynth、FFmpeg - **主要已驗證聲庫:** IA_ROCKS - **本文描述的基線:** local commit `91545a0`,並包含後續 paired-delivery convention - **當時自動驗證:** 47 tests discovered,45 passed,2 intentional skips,0 failed - **English edition:** [From a Blank Timeline to a Finished VOCALOID Song](from-blank-timeline-to-finished-vocaloid-song.en.md) --- ## 摘要 這個專案起源於一個看似很簡單的念頭:把 VOCALOID 暴露成 MCP server,讓 coding agent 幫忙做一首 Vocaloid 歌。 真正麻煩的字是:**歌**。 一個成功的系統不能停在輸出 Standard MIDI File、丟出幾顆 note、轉換一份既有 VSQX,或讓 Editor 唸幾個孤立音節。我們真正想要的體驗比較像這樣: > 給 agent 一份創作 brief、歌詞,甚至一條完全空白的 timeline。讓它設計 form、melody、harmony、rhythm、phoneme、vocal expression、accompaniment、tempo/meter 變化、mix intent 與 delivery target。接著由同一個 agent 產生原生 VOCALOID project,透過 original Editor 和合法聲庫渲染人聲,組裝 stems、mastering、分析性聆聽、局部修改,最後交付一份有 provenance、可驗證的 stereo WAV。 這個要求把「寫一點 XML」變成一套小型 production system。它要求我們: - reverse engineer 足夠多的 32-bit legacy Windows application,才能安全自動化; - 理解 Yamaha VSQ3/VSQ4 data model; - 建立適合長時間 agent session 的 canonical song representation; - 把 creative intent 與 derived artifacts 分開; - 建立 deterministic accompaniment 與 audio-processing backends; - 最重要的是,把 interaction cost 壓到 fresh agent 不必每次重新發現 schema。 本文重建了從第一個 native probe,到三套完整 IA_ROCKS delivery pair 的工程路徑。Dead end、crash、錯誤假設、interface redesign、品質失敗與 test evidence 都會保留。同時,它也嚴格區分:什麼真的被證明了,什麼仍需要更好的樂器、更廣的 voice coverage、人耳判斷或下一階段 protocol。 這不是在聲稱軟體已經解決音樂品味。它記錄的是:我們做出了一件可審計的樂器,讓 agent 可以在其中行使音樂判斷。 --- ## 目錄 1. [真正的問題:完整製作,不是 MIDI generation](#1-真正的問題完整製作不是-midi-generation) 2. [限制與 definition of done](#2-限制與-definition-of-done) 3. [最終系統總覽](#3-最終系統總覽) 4. [Phase I:考古、schema 與 native reverse engineering](#4-phase-i考古schema-與-native-reverse-engineering) 5. [Phase II:從零產生 native VSQX](#5-phase-ii從零產生-native-vsqx) 6. [Phase III:安全自動化 original VOCALOID3 Editor](#6-phase-iii安全自動化-original-vocaloid3-editor) 7. [Phase IV:從 vocal snippet 到 structured song](#7-phase-iv從-vocal-snippet-到-structured-song) 8. [Phase V:長曲、快速歌詞、配器與 mastering](#8-phase-v長曲快速歌詞配器與-mastering) 9. [Phase VI:canonical song manifest](#9-phase-vicanonical-song-manifest) 10. [Phase VII:日文歌詞與可檢查 tuning gesture](#10-phase-vii日文歌詞與可檢查-tuning-gesture) 11. [Phase VIII:stems、score/render 分析與可重現混音](#11-phase-viiistemsscorerender-分析與可重現混音) 12. [Phase IX:preflight、host readiness、history 與 delivery](#12-phase-ixpreflighthost-readinesshistory-與-delivery) 13. [Phase X:為 agent 重設計 MCP](#13-phase-x為-agent-重設計-mcp) 14. [完整 production workflow](#14-完整-production-workflow) 15. [獨立 agent evaluations](#15-獨立-agent-evaluations) 16. [三種完整 style closure](#16-三種完整-style-closure) 17. [Failure ledger](#17-failure-ledger) 18. [測試與證據策略](#18-測試與證據策略) 19. [Chronological checkpoints](#19-chronological-checkpoints) 20. [Repository map 與 reproducibility](#20-repository-map-與-reproducibility) 21. [安全、provenance 與操作邊界](#21-安全provenance-與操作邊界) 22. [已證明、未證明、下一步](#22-已證明未證明下一步) 23. [可泛化的工程教訓](#23-可泛化的工程教訓) 24. [附錄:production tools 與 resources](#24-附錄production-tools-與-resources) --- ## 1. 真正的問題:完整製作,不是 MIDI generation 很多「AI music」整合把 MIDI 當成邊界。這很合理:MIDI note 容易生成、驗證,也容易送進樂器。但一段 Vocaloid performance 含有普通 MIDI 無法忠實表達的資訊: - lyric 與 language-specific phoneme; - singer identity 與 voicebank component binding; - 作為 consonant timing、而非常規 loudness 的 note velocity; - accent、decay、opening、bend depth/length、portamento flags; - vibrato type、onset、depth envelope、rate envelope; - 隨時間變化的 DYN、BRE、BRI、CLE、GEN、POR、PIT、PBS; - musical part、pre-measure、mixer 與 singer events; - licensed synthesis 與 project compatibility 等原生 Editor 行為。 只輸出 MIDI 的 agent 可以提出 melody,卻不能聲稱自己建立了真正的人聲 performance。同樣地,只生成 VSQX、卻從未讓 target Editor 打開的系統,只證明自己的 XML parser 滿意,沒有證明 VOCALOID 接受、渲染或保留它。 因此我們採用一個更強的定義: > 只有當 agent 能在沒有 input VSQX 的情況下起步,把音樂與 production intent 保存於可檢查的 canonical model,compile 原生 artifacts,透過 original Editor 渲染指定合法聲庫,製作 accompaniment 與 isolated stems,依明確 target mastering,執行獨立 delivery checks,並保留足以重現或修改的 provenance,MCP 才算完成。 這個定義改變了所有 architecture decision。VSQX 成為 derived format,而不是唯一 database;audio analysis 進入 workflow,而不是事後補充;tool design 必須同時考慮 capability、context cost、retry cost 與 mutation safety;一首長曲要能承受數十次呼叫,而不是每次都讓 agent 重送幾千顆 events。 ### 1.1 Agent-assisted 不等於把 agent 藏起來 Agent 仍然負責藝術選擇:form、section energy、melodic contour、tessitura、chord tension、rapid syllabic writing、breath、rest、melisma、harmony entrance、tempo change、stereo placement、effect intent,以及判斷 warning 是 bug 還是風格決定。 MCP 提供 affordance 與 guardrail。它不會在單一 `make_song` 按鈕後面偷偷做一首通用歌曲,也不會把所有特殊段落自動修成平淡安全。Analyzer 回報可觀察的風險,不用數字 threshold 取代 taste。 ### 1.2 為什麼「from zero」很重要 我們完全可以拿一份 known-good VSQX,替換 note,再稱之為 generation;但我們明確拒絕這條捷徑。最早的獨立 Codex proof 在沒有讀取或複製既有歌曲的情況下,建立一份八小節、41 顆原創 note、62 個 control points 的 project。之後 Yamaha native loader 從中列舉出 351 個 objects。 既有 projects 只作為 format 或 behavior oracle,用於比較 native structure、object tree 與 Editor behavior;它們從未成為最終作品背後的隱藏旋律模板。 ## 2. 限制與 definition of done ### 2.1 Legacy application boundary VOCALOID3 Editor 與它的 libraries 是 32-bit Windows software;大部分 orchestration 和 MCP 實作則在 Linux/WSL 的 Node.js 上執行。Native validation 與 rendering 必須跨越 OS 與 architecture: ```text Codex / MCP client | | JSON-RPC over stdio v Node.js TypeScript MCP server in WSL/Linux | | validated Windows paths + bounded subprocess protocol v 32-bit native Windows helpers | +--> Yamaha Vsq3.dll loader/probe | +--> original VOCALOID3 Editor UI and licensed synthesis ``` 這也是 repository 同時出現 TypeScript、C 與 PowerShell 的原因。假裝 Editor 是普通 HTTP service,只會把最難的 reliability 問題藏起來。 ### 2.2 Original Editor 是 synthesis authority 找到 VVD metadata,不代表 singer 已註冊、有 license,或能被目前 Editor 使用。只有真實 render 能證明 availability。Production workflow 中,original VOCALOID3 Editor—not a reimplementation—才是聲音合成 authority。 這也劃出 licensing boundary:reverse engineering 用於理解 file loading 與合法安裝行為,不 patch activation、不繞過 registration、不散布 voice data,也不假裝能取代 licensed engine。 ### 2.3 Local、single-user MCP transport 目前 MCP 使用 `stdio`,適合作為 local desktop bridge。它避免把 legacy Editor 與 filesystem path 暴露到 network。若未來要 remote service,需要 authentication、tenant isolation、secret management 與完全不同的 threat model;目前設計不暗示已具備這些能力。 ### 2.4 一個被完整驗證的 production voice 最終 style evaluations 使用 IA_ROCKS exact component ID: ```text BDREB7P2KTWKYDC5 ``` 另一個本地 ID `BLRGDDR4M3WM2LC6` 是 IA,不是 IA_ROCKS。曾經混淆一次,就足以證明我們需要單一 canonical constant 與 active voice-readiness probe。Architecture 支援其他 voice,但本文 checkpoint 的完整 end-to-end evidence 僅屬於 IA_ROCKS。 ### 2.5 Completion matrix | Layer | 必要證據 | | --- | --- | | Composition | 可以從 empty manifest 建立新歌,不需要 source VSQX。 | | Lyrics | original text、kana reading、normalized reading、mora alignment、locked phoneme 可區分。 | | Vocal expression | high-level intent 能 compile 成可檢查的 note style、vibrato 與 control curves。 | | Structure | 支援多 sections、tracks、parts、tempo、meter 與 reusable patterns。 | | Native compatibility | XSD 與 Yamaha `Vsq3.dll` 都接受生成的 VSQX。 | | Voice synthesis | Original Editor 用指定 singer 渲染 non-silent audio,不能 substitution。 | | Accompaniment | 多樂器與 drums 能渲染成 verified stereo audio。 | | Iteration | stable IDs 與 bounded edits 能修改局部,不必重送整首歌。 | | Stems | Vocal/instrument 可分軌渲染,pan/dry 與 provenance 明確。 | | Mix | ordered effects 與 section dynamics deterministic,並保存為 intent。 | | Master | LUFS、LRA、true peak、clipping、balance 獨立量測。 | | Delivery | 最終 WAV 只有在 dependency 與 hashes current 時通過,並發布同 basename VSQX。 | | Recovery | 失敗 render 不產生假 artifact,先前成功工作可以 resume。 | | Agent usability | 預設 tool catalog compact、typed、有 docs 與 on-demand resources。 | ## 3. 最終系統總覽 成熟系統可以視為五個平面: ```text CREATIVE / CONTROL PLANE Agent brief, lyrics, revisions, listening notes | v production MCP profile + resources typed outputs | dry-run | preflight | v canonical *.song.json timeline | form | harmony | vocals | arrangement | mix | review | +----------------+----------------+ | | v v NATIVE VOCAL PLANE INSTRUMENT PLANE VSQ3/VSQ4 compiler patterns/placements XSD + native loader FluidSynth + SF2 VOCALOID3 Editor per-track stems | | +----------------+----------------+ v AUDIO PRODUCTION PLANE alignment -> effects -> automation stem sum -> bus -> analysis -> master | v EVIDENCE / DELIVERY PLANE hashes | dependencies | history | reviews | QC ``` ### 3.1 Implementation layers | Layer | 代表 modules | 責任 | | --- | --- | --- | | MCP routing | `src/index.ts`、`agent-examples.ts`、`style-palettes.ts` | profiles、schema、resources、high-level routing | | Canonical state | `song-manifest.ts`、`manifest-history.ts`、`mutation-preview.ts` | IDs、hashes、revision、backup、dry-run、artifact graph | | Musical compilation | `vsqx.ts`、`vocal-phrase.ts`、`japanese.ts`、`harmony.ts`、`tempo.ts` | native structures、lyrics、phonemes、gesture、harmony/groove guardrails | | Rendering | `render.ts`、`voice-readiness.ts`、`accompaniment.ts`、`stems.ts` | Editor export、voice probe、FluidSynth、isolated stems | | Audio production | `stem-mix.ts`、`audio-quality.ts`、`audio-review.ts`、`delivery.ts` | effects、automation、analysis、A/B、mastering、delivery | | Native boundary | `native/vsq_probe.c`、`native/vocaloid_export.c` | 32-bit loader inspection 與 Win32 automation | | Verification | `tests/`、`notes/`、local `artifacts/evals/` | unit、integration、protocol、routing、full-song evidence | ### 3.2 為什麼 canonical manifest 必須在中心 VSQX 適合作為 Editor interchange format,卻不適合當 agent production system 的唯一 source of truth。它不自然保存 renderer choices、mix chains、artifact hashes、review notes、dependencies 與 mutation history。 因此 `.song.json` 保存 creative/production intent;VSQX、backing、stems、mix、analysis、mastered WAV 都是 derived artifacts。這個區分是 reproducibility 與誠實 staleness detection 的基礎。 ## 4. Phase I:考古、schema 與 native reverse engineering ### 4.1 從文件與 schema 開始,不靠猜 本地 VOCALOID3 安裝提供三個互補 truth sources: 1. Editor manual,特別是 phoneme 與 expression semantics; 2. bundled VSQ3/VSQ4 XML schemas; 3. Editor-produced projects 與 native loader behavior。 XSD 檢查 shape 與 bounds;manual 解釋日文 phoneme 與 note property;native loading 暴露 schema 無法表達的 compatibility 要求。三者共同避免系統被單一 sample 的偶然細節綁死。 ### 4.2 Binary address 一定要綁 fingerprint | Binary | Architecture | SHA-256 | | --- | --- | --- | | `DSCL3.dll` | PE32 / Intel 80386 | `9bcdc8b8424849f18975af47ceaad984222239ddad57d1554e75b2478fb5f789` | | `DSE3.dll` | PE32 / Intel 80386 | `f251e7105eee2c8ceb8e632bf22ff50655cb7b87b7e892b6116b3b17c6a4ee5f` | | `Vsq3.dll` | PE32 / Intel 80386 | `236b4be5c09d17f77e5f9c9a7455817edba01664e760908635157eef2dce7256` | Proprietary DLL 裡的 address 不是 API,不能假設跨版本穩定。Native helper 動態 resolve decorated exports;reverse-engineered address 只記錄 pinned build,絕不是 universal entry point。 ### 4.3 找回 native object tree 第一個真正有用的 bridge 不是 synthesizer,而是 validator。 `native/vsq_probe.c` 透過 Yamaha `Vsq3.dll` 載入 VSQX、初始化 `CVSVsqManagerIF`、呼叫 `fileLoadVsqFile`,再走訪 object hierarchy。這要求理解 VC9 `std::wstring`、interface offsets、generic `IVSVsqObject`、pointer-vector layout 與 primary vtable identities。 Probe 在兩份差異極大的 projects 上驗證:一份真實 V4 corpus project 有 20,402 objects、6 tracks、6 parts;早期 smoke project 有 83 objects、1 track、1 part。這比單純 XML parse 強得多。 ### 4.4 Native validation 修正了我們自己的錯誤直覺 一次 load failure 被錯怪到 phoneme `4 a`,彷彿 `4` 是 count 或非法 token。Manual 與 `KanaNote.lua` 卻證明 `4` 正是日文 ら 行的官方 flap/tap phoneme。 真正問題在別處:phoneme element 要保存 raw symbol、每顆 note 要有標準 note-style/vibrato fields、string elements 要符合 Editor 的 CDATA 行為。修正後,一份包含 `4 a`、note styles、vibrato sequence 與 DYN 的 project 被 native loader 接受為 77 objects。 這形成一條規則:**validator 應報告 observed facts,不能替我們的直覺背書。** ### 4.5 Direct DSCL/DSE synthesis 的迷人死路 IDA 顯示一條可能的 native path: ```text VSQX -> CVSVsqManagerIF / IVSMusicalPart -> sequence time map -> CxDaisyMidiFile::EncodeMusicalPart -> CDaisyMidiBuffer -> CRtSynthesis::OpenSynthesizer -> DSE3 step synthesis -> CWaveFile ``` Recovered contracts 包括 API version `20008017.0`、engine token `20012012.0`、256-sample frame,以及 `EncodeMusicalPart` 對 musical part 和 time map 的需求。Probe 已走到 load VSQX、select part、create map、encode Daisy、load DSCL3/DSE3、resolve exports。 真正 synthesis 停在: ```text DSESetDBMPath result=-100 DoSynthesis failed render_status=71 ``` Decompilation 顯示參數不是普通 voice directory,而涉及 `SOFTWARE\VCLDASGN3\%s` 與 32-bit registry 下的 `DATABASE\VOICE2`/`VOICE3` registration state。 正確決定是停止把 direct DSE 當 production path。我們不 patch activation、不模擬 undocumented voice table。Original Editor 本來就擁有合法合成 context,因此 automation 向上移到 application boundary。 ### 4.6 Dead end 仍然是 deliverable 這段調查留下 Yamaha-loader compatibility test、binary fingerprint/ABI boundaries、native synthesis 保留 VOCALOID expression 的證據、licensing/registration boundary,以及採用 Editor automation 的可解釋理由。 Systems work 裡,一條被完整描述、然後有紀律放棄的路,本身就是成果。它防止下一個 maintainer 重複同一個危險實驗。 ## 5. Phase II:從零產生 native VSQX ### 5.1 Timing model Writer 使用 VOCALOID 的 480 ticks per quarter note。High-level position 是 zero-based: ```text measure, beat, tick ``` 它們透過 tempo/meter map 轉換。Part-local editing 與 song-global placement 必須分開,否則很容易被 pre-measure 或 part offset 整段平移。 Structured writer 支援 VSQ3/VSQ4、最多 16 vocal tracks、多 parts、tempo/meter changes、mixer、mono/stereo WAV audio parts,以及 note styles、vibrato、master curves。 ### 5.2 Native note content 一顆 note 不只是 pitch、onset、duration。Writer 保存 lyric、locked phoneme、velocity/consonant timing、accent、decay、opening、bend、portamento、vibrato type/length 與 normalized depth/rate envelope。 Native control domains 是: ```text DYN BRE BRI CLE GEN POR PIT PBS ``` PIT 為 `-8192..8191`,PBS 為 `0..24` semitones,其他 master curves 為 `0..127`。所有範圍都在 Editor 前驗證。 ### 5.3 Validation 是一個 stack,不是一個 boolean 每份 project 依次經過 Zod/input checks、semantic bounds/overlap/reference validation、temporary sibling write、XSD validation、selected native-loader fixtures、Editor integration,以及最後 atomic move。沒有任一層可以代替其他層。 ### 5.4 第一份 from-zero agent proof 一個只能使用 Vocaloid MCP、不能使用 shell/raw XML 的 Codex session,從 abstract brief 建立 8 measures、132 BPM、4/4 的 original IA_ROCKS project:41 vocal notes、locked Japanese phonemes、34 DYN、6 PBS、22 PIT、expressive note styles、3 個 long-note vibratos。 它通過 schema 與 semantic validation;Yamaha loader 列舉出 351 objects、1 track、1 part。這證明 MCP 可以從 empty starting point 建立真正 native vocal project。 它還不是 finished song,因為尚無 accompaniment、mix、artifact history 或 delivery gate;但 generation 而非 template mutation 的核心主張已成立。 ## 6. Phase III:安全自動化 original VOCALOID3 Editor ### 6.1 Command 與 dialog contract Win32 menu enumeration 找到: ```text File -> Export -> Wave... command ID 33299 ``` Export 是兩段 dialog transaction:VOCALOID 的 **Export Wave File** options,以及 Windows 的 **Export to Wave File** Save dialog。Dialog window 出現時,child controls 未必已建立,尤其在 offscreen/no normal Explorer shell 的環境。 ### 6.2 第一個 cleanup crash Prototype 太早 enumerate Save dialog,找不到 filename control,然後在 modal 仍 active 時關閉 disabled MFC owner,導致 VOCALOID3 access violation。 這不是 synthesis bug,也不是 malformed VSQX,而是 automation state-machine bug。 修正版會等待 filename/Save controls、只 hook `EVENT_OBJECT_SHOW`、依 title/structure/process owner 識別 dialog、先取消 known modal、等待 owner enabled、必要時只 terminate helper-owned process,且不向未知 UI state 盲送 close。 Save 後還要觀察 output 在四次 250 ms check 中穩定。Pre-Send adjustment 必須由 caller 明確允許,而且 result 區分 permission、dialog observed 與 adjustment actually accepted。 ### 6.3 Singer substitution 必須 fail closed 若 requested voice unavailable,Editor 可能詢問是否改用 default singer。自動按 Yes 會得到 valid-looking audio 和虛假 provenance。 Helper 會 match dialog、回傳 `singer_unavailable`、拒絕 render。`list_voices` 只說 metadata exists;成功 `probe_voice` 才證明 current Editor 能合成 exact component。 ### 6.4 Render 是 transaction `vocaloid_render_wav` 會 validate VSQX、fingerprint binaries、acquire host-wide lease、選 temporary WAV、launch/observe/cancel、等待 stable output、parse RIFF/PCM、拒絕 silence/malformed sample count、atomic rename、release lease、cleanup owned process。 Existing destination 需要 explicit overwrite,並先建立 timestamped backup。失敗 render 不得在 requested final path 留假檔案。 ### 6.5 Fingerprint、progress、cancel 與 lease Bridge 只認 pinned Editor 3.2.1.1;unknown fingerprint 預設拒絕。Progress 暴露 validating、fingerprinting、lease、launching、synthesizing、verifying、committing、cleanup 八個 stage。 Host lock 在 `build/runtime/vocaloid-editor-render.lock`,包含 lease ID、PID、request ID、acquired time。只有 age threshold 加 dead-owner check 才能 reclaim;release 仍需 matching lease ID。這防止兩個 agent 同時搶一個 desktop Editor。 ### 6.6 第一批 hardened exports | Project | Helper runtime | Audio | Peak | RMS | | --- | ---: | --- | ---: | ---: | | Japanese `4 a` smoke | 13.657 s | 10.008 s,44.1 kHz,16-bit stereo | -18.47 dBFS | -38.46 dBFS | | Codex-created `雨のあとで` | 14.641 s | 16.370 s,44.1 kHz,16-bit stereo | -7.92 dBFS | -23.01 dBFS | 到這裡,最小閉環成立:agent 建 project,original Editor 輸出 non-silent audio,而且不留下殘餘 process。 ## 7. Phase IV:從 vocal snippet 到 structured song ### 7.1 Song-scale model `vocaloid_create_song` 支援 multi vocal tracks/mixer、multi named parts、tempo/meter maps、measure/beat/tick positions、mono/stereo audio parts、tempo-aware duration 與 pre-measure-aware placement。這是 lead、harmony、backing 第一次能同時存在同一 project。 一份 integration fixture 含 2 simultaneous IA tracks、1 stereo backing、6 notes、4 DYN、1 WAV part;result 為 6.014 s、stereo、non-silent,peak -13.26 dBFS、RMS -25.32 dBFS。 ### 7.2 Audio parts 是 reference,不是 embedded assets VOCALOID audio part 只引用外部 WAV。Server 在寫 project 前驗證 16-bit PCM、44.1/48/96 kHz、mono/stereo、RIFF structure,並自行計算 play time。WSL path 還必須轉成 Windows-readable path;移動 WAV 就會破壞 reference。這是 reproducibility 必須公開的行為。 ### 7.3 為什麼 accompaniment 可以內部用 MIDI,但產品不能停在 MIDI FluidSynth 2.3.4 與 FluidR3 GM 成為第一個 deterministic backend。Canonical arrangement 保存 typed notes、drum hits、tempo/meter、mixer、patterns、placements;renderer 才暫時轉成 format-1 SMF、呼叫 FluidSynth、驗證 PCM、刪除 temporary MIDI。 MIDI 是一個 renderer 的 internal transport;vocal performance 仍是 native VSQX/original Editor;未來 VST/DAW backend 可替換 FluidSynth,而 stable song positions 不變。 FluidR3 GM 明確只是 **draft-quality** timbre backend。Program 106 被命名為 shamisen,不代表它有真實三味線演奏法。 ### 7.4 16-measure experiment 第一首 song-scale experiment 有 intro、verse、pre-chorus、chorus、128→132 BPM、176 pitched notes、127 drum hits、56 lead notes、12 harmony notes。Original-Editor master 40.263 s。 結構成功,聲音卻暴露下一層缺陷:raw export 約 -9.0 LUFS、13.5 LU LRA、+0.3 dBTP,且有 9,844 個 full-scale samples。那不是 master,而是 clipped source。於是 audio-quality plane 成為必要工作。 ## 8. Phase V:長曲、快速歌詞、配器與 mastering ### 8.1 Phrase compiler `vocaloid_compile_vocal_phrase` 接受 1/16、1/32、1/64、dotted、tuplet、rest、gate、pitch、velocity、style、vibrato、sequential lyric allocation 與 explicit melisma index。 同一 lyric index 重複時,native continuation 是: ```text lyric="-" phonemes="-" ``` 這讓 agent 表達 rapid syllabic passage 或 melisma,不需手工管理每顆 low-level note,也不創造非原生格式。 ### 8.2 Reusable patterns 與 placements 長曲不能輸入幾千個重複 events。Arrangement 將 compact pattern 與 placements 分離;placement 可選 section、repeat、transpose、velocity scale 等 bounded transform。 一個 reference 只用 8 source events 與 2 placements,就展開成 96 measures、192 shamisen notes、384 drum hits,仍 deterministic 且可檢查。 ### 8.3 Audio analysis 與 two-pass mastering Analyzer 結合 PCM inspection 與 FFmpeg EBU R128,回報 duration、format、sample peak、RMS、crest、LUFS、LRA、true peak、full-scale count、per-channel levels 與 imbalance。 Masterer 寫新 output,執行 measured two-pass normalization,再重新分析,絕不相信 request 本身。它也明確承認:loudness normalization 無法還原已被 clipping 摧毀的 transient。 修正後 16-measure experiment 為 -13.8 LUFS、-1.0 dBTP、zero full-scale samples。後續也加入 true-peak corrective gain 與 +0.05 dB bounded tolerance。 ### 8.4 96-measure stress test `月影疾走` 有 172.408 s、96 measures、10 tempo events(96–156 BPM)、4/4→6/8→4/4、9 instrument/drum roles、81 placements、3,128 pitched events、861 drums、311 lead notes、85 harmony notes、41 controls。 第一版 vocal mix 嚴重偏左,因為 agent 以為 pan `0` 是 center。VOCALOID native mixer 實際為: ```text 0 = hard left 64 = center 127 = hard right ``` 結果 L/R RMS 相差 17.196 dB。加入 mixer inspection/update、schema docs 與 per-channel analysis 後,lead=64、harmony=96,raw balance 改到 0.583 dB;final master -14.2 LUFS、-1.0 dBTP、zero clipping、12.6 LU LRA。 LRA target 是 9 LU,因此系統誠實回報 miss,沒有拿其他綠色 metrics 冒充 full success。另一次 Editor 無 WAV exit,也因 temporary/verify/atomic commit 沒留下假 artifact,retry 後才成功。 ### 8.5 Artifact naming 也是 usability ```text -backing-v1.wav .vsqx -mix-v1.wav -master-v1.wav -