音频生成服务

Audio Gen MCP Server是一个模块化的音频生成服务,支持通过编程方式生成合成音频、循环和效果。

  • by sam2332
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 sam2332/MCP-audio-gen

使用说明

音频生成器MCP服务器

一种模块化的模型上下文协议(MCP)服务器,用于以编程方式生成合成音频、循环和效果。

特性

  • 模块化合成引擎:基于插件架构(振荡器、噪声等)构建。
  • 通用符号:使用简化的JSON“Score”格式来表示曲目、笔记和事件。
  • 分层:支持用不同乐器混合多首曲目。
  • WAV出口:在本地生成高质量的44.1kHz WAV文件。
  • 测试:Vitest的完整测试套件。

可用仪器

  • 合成器:

    • oscillator:基本波形(正弦、方形、锯齿形、三角形)。
    • saw-synth:一个丰富的锯齿合成器,用于铅和低音。
    • pad-synth:大气垫声音。
    • noise:噪声发生器(白色、粉红色、棕色)。
  • 声学/电气:

    • piano:基础合成钢琴。
    • acoustic-guitar:弹拨原声吉他仿真。
    • electric-guitar:扭曲的摇滚吉他。
    • electric-bass:清洁的电贝司。
  • 鼓:

    • kick:电子踢鼓。
    • snare:合成小鼓。
    • hihat:金属高帽(封闭式/开放式)。

工具

1. list_instruments

返回可用仪器插件及其预设的列表。

2. generate_sound

快速生成单个声音效果或音符。

  • 参数:
    • instrument (字符串):乐器ID(例如“钢琴”、“踢腿”)。
    • note (string):注意名称(例如“C4”)或频率。
    • duration (数字):持续时间(秒)。
    • preset (可选字符串):要使用的特定预设。
    • filename (string):输出文件名(例如“sound.wav”)。

3. render_score

渲染复杂的多轨迹合成。

  • 参数:
    • score (JSON字符串):包含节奏和曲目的结构。
    • filename (string):输出文件名。

分数格式示例

{
  "tempo": 120,
  "tracks": [
    {
      "instrumentId": "kick",
      "events": [
        { "note": "C2", "duration": 0.1, "startTime": 0, "velocity": 1.0 },
        { "note": "C2", "duration": 0.1, "startTime": 1, "velocity": 1.0 },
        { "note": "C2", "duration": 0.1, "startTime": 2, "velocity": 1.0 },
        { "note": "C2", "duration": 0.1, "startTime": 3, "velocity": 1.0 }
      ]
    },
    {
      "instrumentId": "piano",
      "events": [
        { "note": "C4", "duration": 0.5, "startTime": 0, "velocity": 0.8 },
        { "note": "E4", "duration": 0.5, "startTime": 0.5, "velocity": 0.8 },
        { "note": "G4", "duration": 0.5, "startTime": 1.0, "velocity": 0.8 }
      ]
    }
  ]
}

设置和开发

安装

npm install

构建

npm run build

MCP配置

将此添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "audio-gen": {
      "command": "node",
      "args": [
        "D:\\mcp\\audio-gen\\dist\\index.js"
      ]
    }
  }
}

项目结构

  • src/core:音频引擎逻辑(混音器、Utils)。
  • src/plugins:仪器实施。
  • src/interfaces:共享TypeScript接口。
  • src/index.ts:MCP服务器入口点。