const ChannelStripDevice = ({ input, output, gain, balance }) => {
  for (let c = 0; c < input.length; c++) {
    const inputChannel = input[c];
    const outputChannel = output[c];
    for (let s = 0; s < outputChannel.length; s++) {
      const balanceMultiplier = c === 0
        ? Math.min(1, -1 * (balance[s] - 1))
        : Math.min(1, balance[s] + 1);
      outputChannel[s] = inputChannel[s] * gain[s] * balanceMultiplier;
    }
  }
}

this.constructDevice = () => constructPerBufferDevice({
  implementation: ChannelStripDevice,
  inputs: {
    input: stereo('In'),
    gain: dbSetting('Gain', { defaultValue: 0, min: -Infinity, max: 12 }),
    balance: numberSetting('Balance', { defaultValue: 0, min: -1, max: 1 }),
  },
  outputs: {
    output: stereo('Out'),
  }
});
