关于 midi-synth
midi-synth 是一项将 MIDI 或 MusicXML 转为 Strudel 模式和音频的技能,面向音乐创作者。它可依据力度、时长及可用的调性分析清理幽灵音符。
主要功能
- 01支持 MIDI 和 MusicXML
- 02生成 Strudel 模式
- 03渲染 WAV 和 MP3
- 04按力度和时长过滤幽灵音符
- 05基于调性过滤音符
适用场景
- 01从乐谱生成 Strudel 代码
- 02将 MIDI 渲染为 WAV 或 MP3
- 03利用分析数据清理杂音
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ maystudios/ claude-skills --skill midi-synth安装后在 Claude Code 中输入/midi-synth确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
scripts/render.pyto_strudel.pysoundfonts/README.md详细介绍
MIDI Synth
将 MIDI/MusicXML 合成为音频,并生成 Strudel 实时编程模式。 使用分析数据清理幽灵音符、校正节奏并进行基于调性的筛选。
脚本
scripts/to_strudel.py—— 将 MIDI/MusicXML 转换为 Strudel 模式,采用感知时值的记谱法scripts/render.py—— 将 MIDI/MusicXML 转换为 WAV/MP3,并进行清理和修改
这两个脚本都会自动检测 audio-to-midi 生成的 *_analysis.json 文件,以获取节奏、调性和力度信息。
工作流
- 确定输入类型:MIDI(.mid)或 MusicXML(.musicxml)
- 自动检测或指定来自 audio-to-midi 的分析 JSON 文件
- 选择工作流:
- 创作:
to_strudel.py生成可用于 strudel.cc 的 Strudel 代码 - 渲染:
render.py生成 WAV/MP3 - 两者: 对同一输入同时运行这两个脚本
- 创作:
- 自动根据力度、时值和调性筛选器清理幽灵音符
Strudel 代码生成
# Basic (auto-detects analysis JSON next to input)
py -3.12 scripts/to_strudel.py "song.mid"
# From MusicXML
py -3.12 scripts/to_strudel.py "song.musicxml"
# Explicit analysis file
py -3.12 scripts/to_strudel.py "song.mid" --analysis "song_analysis.json"
# Stricter ghost-note filtering
py -3.12 scripts/to_strudel.py "song.mid" --min-velocity 60 --min-duration 0.1
# Open in browser
py -3.12 scripts/to_strudel.py "song.mid" --open
| 标志 | 默认值 | 效果 |
|---|---|---|
--analysis | 自动检测 | 用于获取节奏/调性的分析 JSON 路径 |
--bars | 4 | 模式长度,单位为小节 |
--resolution | 16 | 网格:4/8/16/32 |
--min-velocity | 40 | 移除力度低于此值的音符(0-127) |
--min-duration | 0.05 | 移除时值短于此值的音符(秒) |
--no-key-filter | 关闭 | 禁用基于调性的幽灵音符筛选 |
--tempo | 来自分析 | 覆盖节奏 BPM |
--open | 关闭 | 在浏览器中打开 strudel.cc |
音符时值使用 @N 记谱法编码(例如,c3@4 表示持续 4 步)。
音频渲染
# Basic (auto-detects analysis, cleans ghost notes)
py -3.12 scripts/render.py "song.mid" --mp3
# From MusicXML
py -3.12 scripts/render.py "song.musicxml" --mp3
# With SoundFont
py -3.12 scripts/render.py "song.mid" --soundfont "GeneralUser_GS.sf2" --mp3
# Aggressive cleaning
py -3.12 scripts/render.py "song.mid" --min-velocity 60 --min-duration 0.1
# Skip cleaning entirely
py -3.12 scripts/render.py "song.mid" --no-clean
# Modifications
py -3.12 scripts/render.py "song.mid" --tempo 2.0 --transpose 3 --instrument 0
| 标志 | 默认值 | 效果 |
|---|---|---|
--analysis | 自动检测 | 用于基于节奏/调性进行清理的分析 JSON |
--min-velocity | 40 | 幽灵音符力度阈值 |
--min-duration | 0.05 | 幽灵音符时值阈值(秒) |
--no-clean | 关闭 | 跳过幽灵音符移除 |
--no-key-filter | 关闭 | 禁用基于调性的筛选 |
--soundfont | 自动检测 | .sf2 SoundFont 路径 |
--tempo | 1.0 | 节奏缩放系数 |
--transpose | 0 | 上下移调的半音数 |
--instrument | 原始乐器 | 覆盖 GM 音色编号(0-127) |
--mp3 | 关闭 | 同时生成 MP3 |
幽灵音符清理
三个筛选层(按顺序应用):
- 力度筛选器: 移除力度低于
--min-velocity的音符(默认值:40) - 时值筛选器: 移除时值短于
--min-duration的音符(默认值:50 ms) - 调性筛选器: 如果分析数据提供了调性,则移除调外且力度较低(<60)的音符
调性筛选器只会移除同时满足调外和力度低于中等水平的音符,从而保留有意使用的半音进行。
依赖项
自动安装:pretty_midi、numpy、soundfile。
对于 MusicXML 输入:music21(由 audio-to-midi 技能安装)。
可选:pyfluidsynth + .sf2 SoundFont,用于高质量渲染。
运行时:Python 3.12(py -3.12)。
评论
支持 Markdown