mcpField
M
midi-synth

midi-synth

github.com/maystudios创意与媒体2674 次安装11 周前更新
代码仓库

关于 midi-synth

midi-synth 是一项将 MIDI 或 MusicXML 转为 Strudel 模式和音频的技能,面向音乐创作者。它可依据力度、时长及可用的调性分析清理幽灵音符。

主要功能

  1. 01支持 MIDI 和 MusicXML
  2. 02生成 Strudel 模式
  3. 03渲染 WAV 和 MP3
  4. 04按力度和时长过滤幽灵音符
  5. 05基于调性过滤音符

适用场景

  1. 01从乐谱生成 Strudel 代码
  2. 02将 MIDI 渲染为 WAV 或 MP3
  3. 03利用分析数据清理杂音

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/maystudios/claude-skills --skill midi-synth

安装后在 Claude Code 中输入/midi-synth确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

scripts/
render.py
to_strudel.py
soundfonts/
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 文件,以获取节奏、调性和力度信息。

工作流

  1. 确定输入类型:MIDI(.mid)或 MusicXML(.musicxml)
  2. 自动检测或指定来自 audio-to-midi 的分析 JSON 文件
  3. 选择工作流:
    • 创作: to_strudel.py 生成可用于 strudel.cc 的 Strudel 代码
    • 渲染: render.py 生成 WAV/MP3
    • 两者: 对同一输入同时运行这两个脚本
  4. 自动根据力度、时值和调性筛选器清理幽灵音符

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 路径
--bars4模式长度,单位为小节
--resolution16网格:4/8/16/32
--min-velocity40移除力度低于此值的音符(0-127)
--min-duration0.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-velocity40幽灵音符力度阈值
--min-duration0.05幽灵音符时值阈值(秒)
--no-clean关闭跳过幽灵音符移除
--no-key-filter关闭禁用基于调性的筛选
--soundfont自动检测.sf2 SoundFont 路径
--tempo1.0节奏缩放系数
--transpose0上下移调的半音数
--instrument原始乐器覆盖 GM 音色编号(0-127)
--mp3关闭同时生成 MP3

幽灵音符清理

三个筛选层(按顺序应用):

  1. 力度筛选器: 移除力度低于 --min-velocity 的音符(默认值:40)
  2. 时值筛选器: 移除时值短于 --min-duration 的音符(默认值:50 ms)
  3. 调性筛选器: 如果分析数据提供了调性,则移除调外且力度较低(<60)的音符

调性筛选器只会移除同时满足调外和力度低于中等水平的音符,从而保留有意使用的半音进行。

依赖项

自动安装:pretty_midi、numpy、soundfile。 对于 MusicXML 输入:music21(由 audio-to-midi 技能安装)。 可选:pyfluidsynth + .sf2 SoundFont,用于高质量渲染。 运行时:Python 3.12(py -3.12)。

评论

支持 Markdown