内容
# 🎼 AI 音乐创作与 Cursor + Ableton MCP
本项目通过 [AbletonMCP](https://github.com/ahujasid/ableton-mcp) 服务器连接 [Cursor IDE](https://www.cursor.so/) 与 [Ableton Live](https://www.ableton.com/),实现 **基于自然语言的音乐创作**。
通过在 Cursor 中编写提示,您可以生成结构化的 Python 代码来控制 Ableton Live — 创建音轨、剪辑、乐器和 MIDI 内容,通过基于套接字的 API。
---
## 🚀 你可以做到
- 使用简单的中文提示创作音乐
- 在选定的调中生成丰富的和弦进行和旋律
- 自动创建具有旋律、和声、节奏的结构化 MIDI 剪辑
- 在 Ableton Live 中控制播放、 tempo 和乐器加载
- 使用清晰的结构组织音乐,如 *Intro → Build → Climax*
---
## 🧠 工作原理
1. Cursor 使用自定义规则集引导 LLM 朝向音乐结构和理论。
2. 您编写一个提示,例如:
`"创作一首一分钟的情感电影配乐,调为 A 小调,类似《星际穿越》。"`
3. 模型输出 **兼容 MCP 的 Python 命令**:
- `create_midi_track`
- `set_track_name`
- `create_clip`
- `add_notes_to_clip`
- `load_browser_item`
4. 这些命令被发送到 **Ableton MCP 服务器**,并在 Ableton 中实时应用。
---
## 📦 前置条件
- **Ableton Live 10 或更新版本**
- **Python 3.8+**
- **[uv 包管理器](https://docs.astral.sh/uv/getting-started/installation/)**
- macOS: `brew install uv`
---
## 🎛️ 设置说明
### 1. 安装 AbletonMCP
克隆或安装 [Ableton-MCP GitHub 仓库](https://github.com/ahujasid/ableton-mcp):
```bash
npx -y @smithery/cli install @ahujasid/ableton-mcp --client claude
```
✅ 这提供了 Python 和 Ableton 之间的套接字接口。
---
### 2. 安装 Ableton 远程脚本
1. 从 [AbletonMCP GitHub](https://github.com/ahujasid/ableton-mcp) 下载 `AbletonMCP_Remote_Script/__init__.py`
2. 将其复制到您的 **MIDI 远程脚本** 目录:
#### macOS
- `/Applications/Ableton Live XX.app/Contents/App-Resources/MIDI Remote Scripts/`
- 或:`~/Library/Preferences/Ableton/Live XX/User Remote Scripts/`
#### Windows
- `C:\Users\[Username]\AppData\Roaming\Ableton\Live XX\Preferences\User Remote Scripts\`
> 将 `XX` 替换为您的 Ableton 版本(例如 `11`)
3. 创建一个名为 `AbletonMCP` 的新文件夹,并将 `__init__.py` 文件放入其中。
4. 启动 Ableton Live → 首选项 → Link, Tempo & MIDI:
- 控制表面:`AbletonMCP`
- 输入:`None`
- 输出:`None`
---
### 3. 连接 Cursor 到 MCP
在 **Cursor** 中,前往:
`设置 → MCP → 添加新的全局 MCP 服务器`
粘贴以下内容:
```
{
"mcpServers": {
"AbletonMCP": {
"command": "uvx",
"args": [
"ableton-mcp"
]
}
}
}
```
保存并关闭文件
并在终端中运行以下命令:
```bash
uvx ableton-mcp
```
⚠️ 仅运行 **一个** MCP 实例 — 在 Cursor **或** Claude 中,而不是两者。
---
## 🧩 为 Cursor 添加自定义规则
1. 前往 `Cursor → 设置 → 自定义规则`
2. 创建一个新的规则集(或使用用户规则):
**名称:** `音乐创作(Ableton MCP)`
3. 粘贴 [`Cursor-UserRules-MusicProduction.txt`](./Cursor-UserRules-MusicProduction.txt) 的内容
4. 保存规则集并确保其处于活动状态
这些规则引导模型:
- 首先选择调号
- 以功能性和声进行创作
- 编写与和弦匹配的旋律
- 在章节中组织音乐(例如,Intro,Build,Drop)
- 输出干净、可用的 MCP 命令
---
## ✍️ 示例提示
```text
我想创作一首一分钟的电影配乐,灵感来自《星际穿越》。
它应该在 A 小调, tempo 较慢,并分为三部分:
- Intro 具有柔和的钢琴和音垫
- Build 具有低音弦和脉动的节奏
- Climax 具有高音弦、层叠和弦和打击乐
```
Cursor 将响应:
- 调号选择
- 和弦进行(例如,i–VI–III–VII)
- 音轨创建(钢琴、弦乐、打击乐、音垫)
- 剪辑创建和音符数据,使用基于音阶的音高
- 加载 Ableton 浏览器中的乐器命令
---
## 🛠️ 示例 MCP 命令(由 LLM 生成)
```python
create_midi_track(index=0)
set_track_name(track_index=0, name="电影钢琴")
load_browser_item(track_index=0, item_uri="instrument_uri_here")
create_clip(track_index=0, clip_index=0, length=8.0)
add_notes_to_clip(track_index=0, clip_index=0, notes=[
{"pitch": 57, "start_time": 0.0, "duration": 1.0, "velocity": 100, "mute": False},
...
])
```
---
## 🎹 支持的功能
- 🎵 创建/重命名 MIDI 和音频音轨
- 🎹 添加 MIDI 剪辑和音符
- 🥁 从浏览器加载乐器和效果
- 🎛️ 控制 tempo、播放和剪辑触发
- 🧠 查询会话和音轨数据
- 🔄 通过章节和主题构建结构化歌曲
---
## 💡 取得最佳效果的提示
- 具体:定义风格、情感、tempo 和结构
- 提及参考音轨或艺术家(例如,“像 Hans Zimmer 一样”)
- 使用章节语言:*Intro → Build → Drop → Outro*
- 如果不确定,让 LLM 选择调 — 它将指导其他一切
- 审查音符数据的真实性、语气和间距
---
## 📂 文件参考
- [`Cursor-UserRules-MusicProduction.txt`](./Cursor-UserRules-MusicProduction.txt)
一套详细的 LLM 指导规则,以在生成中强制执行音乐理论和结构。
---
## 🧪 故障排除
- 🔌 **连接问题**:确保 AbletonMCP 已加载并且只有一个 MCP 服务器正在运行。
- ⏱️ **超时**:尝试简化您的请求或一次生成一个部分。
- 🔁 **Ableton 中无响应**:重启 Ableton、Cursor 并重新检查远程脚本设置。
---
## 📎 相关链接
- 🎛️ [AbletonMCP GitHub](https://github.com/ahujasid/ableton-mcp)
- 🧠 [Cursor IDE](https://www.cursor.so/)
- 🎓 [uv 包管理器](https://docs.astral.sh/uv/getting-started/installation/)
---
## 📝 许可证
该项目根据 MIT 许可证授权。
请遵循以下许可条款:
- [Ableton Live](https://www.ableton.com/en/legal/)
- [AbletonMCP 项目](https://github.com/ahujasid/ableton-mcp)
---
## 🙏 致谢
- 🔧 基于 [AbletonMCP](https://github.com/ahujasid/ableton-mcp) 由 Siddharth Ahuja 构建
- ✍️ 提示系统设计用于与 Cursor + OpenAI 模型配合使用
- 🎶 灵感来自电影配乐、AI 辅助制作和现代创作工作流