跳转至

Mixer Module Design (mixer_v1)

概述

mixer_v1 是多输入多输出混音矩阵。每个输出通道可配置 N 条 Send 路由(顺序列表模型),每条 Send 独立指定输入通道和混音增益(dB)。支持多 Port 输入。

参数

参数 ID 类型 范围 默认值 说明
enable bool - true 模块启用/禁用
mixOutCount int 1~64 20 输出通道数
mixSrcCount#${outCh} int 0~64 0 输出通道 outCh 的 Send 槽数量
mixSrc#${outCh}_${slotIdx} int -1~255 -1 Send 槽的绝对输入通道索引(-1 = 未分配)
mixGain#${outCh}_${slotIdx} float -96~24 dB 0 Send 槽的混音增益

增益含义

  • 0 dB = 直通(等效 1.0 linear)
  • 范围 -96 dB ~ +24 dB,DSP 端转换为 linear
  • mixSrc = -1 时,该槽对应的 gain 参数可忽略(DSP 跳过该槽)

绝对通道索引

与 ChannelMap 相同机制——输入通道按连入 Port 顺序扁平化编号:

Port 0 (2ch):  absIdx 0, 1
Port 1 (4ch):  absIdx 2, 3, 4, 5
...

多 Port 输入检测

const inputPorts = computed(() =>
  linkStore.connections
    .filter(c => c.target.instanceId === instanceId)
    .map((c, portIdx) => {
      const srcDef = linkStore.getModuleDef(c.source.instanceId)
      const srcMod = linkStore.getModule(c.source.instanceId)
      const ch = srcMod?.config?.channels ?? srcDef?.outputs?.[0]?.channels ?? 2
      return { portIdx, conn: c, channels: ch }
    })
)

UI 布局

┌─ Mixer 调音 ──────────────────────────────────────────────────────┐
│ 输出路数: [20]   输入: 4ch (2 ports)   ⚠ 无输入连线               │
├───────────────────────────────────────────────────────────────────┤
│ ┌─── Out 1 ─── [2 路] [+ 添加源] [清空] ────────────────────┐    │
│ │  ① │ -3.0 dB │  [P0] L (左)                     ▼ │ [✕] │    │
│ │  ② │  0.0 dB │  [P1] Rear L                     ▼ │ [✕] │    │
│ └────────────────────────────────────────────────────────────┘    │
│ ┌─── Out 2 ─── [0 路] [+ 添加源] [清空] ────────────────────┐    │
│ │  无发送路由(静音)                                          │    │
│ └────────────────────────────────────────────────────────────┘    │
└───────────────────────────────────────────────────────────────────┘
  • 每个输出通道为独立卡片
  • 每条 Send:序号 + dB 增益输入框 + 源通道下拉框 + 「✕」移除按钮
  • 增益输入范围 -96 ~ +24 dB,步长 0.1
  • 「已混路数」badge 显示 mixSrc >= 0 的槽数
  • 「清空」按钮将 mixSrcCount 设为 0(静音该输出)

操作逻辑

添加 Send

function addSend(outCh: number) {
  const count = getSendCount(outCh)
  setSendCount(outCh, count + 1)
  writeParam(`mixSrc#${outCh}_${count}`, -1)   // 初始未分配
  writeParam(`mixGain#${outCh}_${count}`, 0)   // 初始 0 dB
}

移除 Send(槽位前移)

function removeSend(outCh: number, slotIdx: number) {
  const count = getSendCount(outCh)
  for (let i = slotIdx; i < count - 1; i++) {
    writeParam(`mixSrc#${outCh}_${i}`, getSendSrc(outCh, i + 1))
    writeParam(`mixGain#${outCh}_${i}`, getSendGain(outCh, i + 1))
  }
  setSendCount(outCh, Math.max(0, count - 1))
}

清空输出

function clearOutputSends(outCh: number) {
  setSendCount(outCh, 0)  // mixSrcCount#outCh = 0
}

持久化

function writeParam(paramId: string, value: number | string) {
  linkStore.setParamValue(instanceId, paramId, value)
  send({ type: 'set_param', instanceId, paramId, value })
}

// 输出路数
writeParam('mixOutCount', outputCount)

// Send 槽数
writeParam(`mixSrcCount#${outCh}`, count)

// 源通道
writeParam(`mixSrc#${outCh}_${slotIdx}`, absInputIdx)

// 增益
writeParam(`mixGain#${outCh}_${slotIdx}`, dbValue)

DSP 内存布局

Offset Size 说明
0 1 enable
1 4 mixOutCount
5 64 × 4 sendCount[0..63] (int,每输出的 Send 槽数)
261 64 × 64 × 4 srcMap[outCh][slotIdx] (int,绝对输入通道索引)
16645 64 × 64 × 4 gainMap[outCh][slotIdx] (float,dB 值)

Total: ~33029 bytes(满配 64 输出 × 64 Send × 2 参数)

与旧版差异

特性 旧版(checkbox + dB 矩阵) 新版(Send 列表模型)
参数 key mixGain#${outCh * maxInputs + inCh} mixSrc#${outCh}_${slotIdx} + mixGain#${outCh}_${slotIdx}
显示方式 N×M 表格,每格 checkbox + dB 每行独立 Send 列表,槽数可配置
可读性 输入通道多时横向过宽 始终紧凑,支持带名称显示
顺序语义 无(以输入通道编号固定位置) 有(Send 槽按添加顺序排列)
"已混"统计 checkbox 勾选数 mixSrc >= 0 的槽数