Writes MIDI scores, renders them to WAV, FLAC, MP3 or OGG with a bundled FluidSynth engine, and engraves them into print-ready A4 PDF scores.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:tefolium/dsh-music-composer
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
音乐生成插件(DeepSeek Harness):需求 → 乐谱 → MIDI → WAV → FLAC/MP3/OGG,并排成可直接打印的 A4 总谱 PDF。
作者 / Author: 双海诗音 in 大肥鱼
模型 / Model: 三个模型接力写成 ——
- 基本架构:Tencent Hunyuan Hy / hy4flash-free
- 0.3 – 0.4:Tencent Hunyuan Hy / hy4std
- 0.5 起:DeepSeek / deepseek-v4.1-flash
版本 / Version: 0.9.5
0.9.5 变更
- 谱面文字语言按操作系统语言决定:中文系统用中文乐器名与曲名,其它系统自动用英文/拼音(Piano / Drums / Erhu / Untitled),不再依赖中文字体
- 判定链:
LC_ALL→LC_MESSAGES→LANG→LANGUAGE(全空时用Intl.DateTimeFormat().resolvedOptions().locale);只有中文分支才做一次字形实测 - 新增设置项
scoreTextLang: auto | zh | en,可显式覆盖 - VexFlow 备选路径的速度/调号标注也随语言切换(
M.M. = 84/Key: C)
0.9.4 变更
score的bpm参数说明改为M.M.=N(Maelzel 节拍器记号),与谱面实际渲染一致——此前写♩=N,但 sans-serif 没有该字形
0.9.3 变更
tools/build-erhu-sf2.py明确适用前提:只有手上已有那套 CC0 二胡采样时才用得上;脚本不下载、不包含采样- 运行时打印前置说明(
--quiet可关),结尾提示 SF2 应放进~/.dsh-music-composer/soundfonts/ - 修 Windows 控制台中文乱码:stdout/stderr 切 UTF-8
tools/README.md新增「什么时候用得上」小节
0.9.2 变更
tools/README.md补上踩过的坑:SF2 名字字段 20 字节、pdta九子块与 EOS、generator 编号(41/43/53)、bag 累积索引、shdr字段布局、音高八度补偿与排查顺序- 供自行转换音源的人少走弯路
0.9.1 变更
- 新增
tools/build-erhu-sf2.py:从 CC0 二胡采样复现erhu.sf2(参数化、支持 8/16/24/32-bit 与多声道 WAV)。采样不随包分发,这里给的是复现步骤。
0.9.0 变更
- 制谱改用 Verovio 排版引擎(LGPL-3.0,WASM):MusicXML → A4 分页 SVG,印刷级排版
- 新增
lib/musicxml.js:tracks → MusicXML(本插件自写) score默认只输出整合 PDF,单独 SVG/PNG 需显式指定- 保留 VexFlow 路径(
engine:'vexflow')作为可替换备选 compose内置任务表:判断不了的三项一次问完(制谱/其它格式/乐章画面),1 分钟无回应按默认(midi+wav、不制谱)- 乐章画面 = 人格插件对各乐章的印象(第一人称文字,写进回复)
0.8.0 变更
- 排版不再自写:接入 Verovio 做 MusicXML → A4 分页 SVG
- 新增
lib/verovio-render.js适配层;smuflTextFont:'embedded'让字形转 path,摆脱系统音乐字体依赖 - 新增依赖
verovio@6.4.1(LGPL-3.0)
0.7.0 变更
- 谱面按印刷规范重做:跨小节长音自动拆段并画连音线(tie),符杠不再越出小节线
- 小节号改为相对乐章起点计算(此前跨乐章会拉长页数)
score新增pdf_path:出谱时直接输出整合 PDF(A4 纵向,所有页一本)- 新增
pdf工具:把一批 PNG/JPEG 或一个目录按顺序拼成整合 PDF(pdf-lib,纯 JS、本地、不联网)
0.6.0 变更
score工具新增midi_path参数:可直接从.mid出谱,不必把上千音符嵌进工具参数(与tracks二选一,midi_path优先)。新增max_tracks限制谱表数。smf.js新增smfToTracks()/smfTempoBpm():把 MIDI 按通道还原成 tracks 结构,并从 tempo 事件读 BPM。
0.5.0 变更
- 新增设置页(DSH 设置 → 音乐生成):默认音源下拉、音源缓存目录、渲染增益、ffmpeg 路径四项可视化配置;改完即生效、不重启插件。
- Config 四字段改为
.volatile():设置表单只投影 volatile 字段,同时支持热更新,避免中断正在渲染的任务。
0.4.0 变更
- 新增
instruments工具:按当前音源查真实音色号(解析 SF2/SF3 phdr),避免照搬 GM 号写错音色 - 新增
multitrack工具:单音色音源(中国笛/箫/口弦/二胡 CC0 采样)按通道分轨渲染后混音 - 新增
finish工具:汇总交付物、提交文件卡片、给出输出目录、询问清理中间文件 - 修复
forceProgram全局误用(曾把 GM 组真实音色号全抹成钢琴);改为按组配置、GM 组不强制 - 修复
defaultSoundfont=auto误选单音色音源的回归(auto 优先 GM 多音色音源);默认改回generaluser-gs - 新增 3 个 CC0 中国民乐单音色音源目录;二胡采样本机转换为 SF2(origPitch 修正)
- 五线谱可另出白底 PNG;谱号按音区自适应
- 合规:补中国民乐 CC0 采样、构建工具(Polyphone / sf2utils 不随包分发)等声明
安装
仓库即标准 DSH bundle。克隆后安装:
dsh plugin --profile <你的profile> add <本目录绝对路径>
重启 Harness,新会话工具列表出现 _dsh_external_dsh_music_composer_* 九个工具。
工具
_dsh_external_dsh_music_composer_instruments— 查当前音源的真实音色号(写谱前必查)_dsh_external_dsh_music_composer_compose— 乐谱 → .mid_dsh_external_dsh_music_composer_render— .mid → .wav → flac/mp3/ogg_dsh_external_dsh_music_composer_score— 乐谱 → 分音色五线谱 SVG(可另出白底 PNG)_dsh_external_dsh_music_composer_soundfont— 音源列举/下载_dsh_external_dsh_music_composer_multitrack— 单音色音源分轨渲染后混音(中国笛箫等专用音源)_dsh_external_dsh_music_composer_finish— 汇总交付物:提交文件卡片 + 输出文件夹 + 询问清理_dsh_external_dsh_music_composer_pdf— PNG/JPEG 或目录 → 整合 PDF_dsh_external_dsh_music_composer_ffmpeg— 可选 ffmpeg 状态/安装
配置(插件设置页,或 profile cordis.patch.yml)
| 配置项 | 默认 | 说明 |
|---|---|---|
defaultSoundfont |
generaluser-gs |
音源:generaluser-gs / fluid-r3 / auto(优先挑缓存中的 GM 多音色音源,绝不误选单音色)/ 自定义 .sf2/.sf3 绝对路径。单音色音源(曲笛/北箫/口弦/二胡)不能设为主音源,须用 multitrack 分组指定。 |
soundfontDir |
~/.dsh-music-composer/soundfonts |
音源缓存目录 |
defaultGain |
0.5 |
渲染总增益 0-2 |
ffmpegPath |
空 | ffmpeg 可执行文件路径。留空自动探测 PATH 与缓存目录;ffmpeg 不在默认位置时填这里。 |
四个字段均为 .volatile():可在设置页直接修改并即时生效(不重启插件),也可写进 profile 配置:
- id: dsh-music-composer
name: '@local/dsh-music-composer'
config:
soundfontDir: 'D:\soundfonts'
defaultGain: 0.5
defaultSoundfont: generaluser-gs
ffmpegPath: 'D:\tools\ffmpeg\bin\ffmpeg.exe'
依赖
FluidSynth 以 WASM 随 npm 依赖分发,目标机无需安装引擎/Python。音源与 ffmpeg 均按需下载、不随包分发。
已知限制
诚实列出来,免得你以为是 bug:
- 同拍和弦按单音记谱:同一轨在同一拍上的多个音只保留第一个(未生成
<chord/>)。单声部旋律不受影响,钢琴式和弦会缺音。 - 跨小节长音按小节截断:Verovio 路径没有生成跨小节
<tie>,长音会在小节线处断开并留下休止。VexFlow 路径(engine:'vexflow')有 tie。 movements不强制分页:乐章标题会标出来,但 Verovio 仍按默认规则自动分页,不保证"每个乐章另起一页"。- 钢琴不合并大谱表:每轨一条谱表,钢琴的高低声部会分两条。
- 拍号固定 4/4:3/4、6/8 的 MIDI 会被按 4 拍切分。
- 强制
scoreTextLang: zh但本机无中文字体:谱面文字会是方块(auto不会走到这条路)。 - 中文曲名在非中文系统会显示
Untitled:给title一个英文/拼音名即可避免。
致谢 / Acknowledgements
这个插件不是凭空长出来的。它站在下面这些人和项目的肩上——其中每一个都是别人的作品,我们只是调用、适配、或者照着它们的文档学:
排版与制谱
- Verovio(RISM Digital Center,LGPL-3.0)— A4 分页排版的真正功臣。我们只做 tracks → MusicXML 的转换,排版是它的。
- VexFlow(Mohit Muthanna Cheppudira 等,MIT)— 早期版本的谱面渲染,现作为可替换备选保留。
- MusicXML 格式规范(W3C Music Notation Community Group)— 公开规范,我们照着它生成 XML。
音频
- FluidSynth(LGPL-2.1)与 js-synthesizer(BSD-3-Clause)— MIDI → 音频的合成引擎,以 WASM 内嵌。
- lamejs(LGPL-3.0,Alex Zhukov / zhuker)、@audio/encode-ogg、@audio/encode-flac(MIT)— 三种有损/无损编码。
PDF 与栅格化
- pdf-lib(Andrew Dillon,MIT)— PNG → 整合 PDF。
- @resvg/resvg-js(MPL-2.0)— SVG → PNG。
- jsdom、@napi-rs/canvas(MIT)— 让 VexFlow 能在 Node 里跑。
音源
- GeneralUser GS、FluidR3 GM,以及曲笛/北箫/口弦三个 CC0 中国民乐采样——CC0 意味着作者放弃了全部权利,但仍值得写一句谢谢。
参考过的项目
- zeroa234/dsh-midi-studio(BSD-3-Clause)— 早期设计阶段参考过它的工具划分与交付流程,详见
THIRD_PARTY_NOTICES.md第三节。
每个组件的版本、许可证全文与合规说明,都在 THIRD_PARTY_NOTICES.md 里;许可证正文在 licenses/ 目录。
我们采用 GPL-3.0-or-later,取依赖链中要求最高的协议。LGPL 的 Verovio、FluidSynth、lamejs 均以独立模块方式调用、未修改源码,符合其再链接要求。Bravura 字体(SIL OFL-1.1)的保留字体名条款也已在声明中标注。
许可证
GPL-3.0-or-later——取依赖链中要求最高的协议,以满足所有上游依赖。完整声明见 THIRD_PARTY_NOTICES.md,许可证全文见 LICENSE。
Links
More in this category
Tencent/WeKnora#dsh-weknora★ 38608
Four read-only tools over a WeKnora knowledge base: list knowledge bases, hybrid passage search, reassemble one document's chunks in order, and WeKnora's own cited RAG or ReAct-agent answer with a resumable session id.
DayuanJiang/next-ai-draw-io#dsh-plugin★ 37289
Draws draw.io diagrams in DeepSeek Harness through the next-ai-drawio MCP server: the link in the reply opens a live preview in the right sidebar, you can edit the diagram by hand, and each AI change is a version you can restore. Node.js 18+; npx downloads the MCP server on first use.
yikart/AiToEarn#dsh-plugin-aitoearn★ 28947
Generate copy, images and short videos, and publish with one click to Douyin, Kuaishou, Xiaohongshu, WeChat Official, Bilibili, Facebook, TikTok and more, covering the full content lifecycle from creation to publishing and monetization.
superdesigndev/treg★ 10049
Tool catalog for agents: search ~2,600 external endpoints (SEO and SERP, backlinks, social, people and company enrichment, ad libraries, scraping) by the task you want done, read each one's parameters and per-call price, then call it with the credential injected server-side. Ships the skill plus an MCP row that stays disabled until TREG_TOKEN is set.
T-Auto/dsh-ops★ 6112
Provides bash, PowerShell 7, and high-performance Rust tools for DSH on Windows to reduce token usage.
Hithink-Tech-Org/Financial-API#hithink-finance★ 4761
Query Hithink Finance data in DeepSeek Harness, view charts in chat, and save refreshable dashboards.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.