const Overdrive125 = ({ input, output, pre, post }) => {
  for (let i = 0; i < input.length; i ++) {
    const x = input[i] * pre[i];
    const absX = Math.abs(x);
    const sign = x > 0 ? 1 : -1;
    const postMultiplier = post[i];
    if (absX < 1/3) {
      output[i] = 2 * x * postMultiplier;
    } else if (absX < 2/3) {
      output[i] = ((3 - Math.pow((2 - (3 * absX)), 2)) / 3) * sign * postMultiplier;
    } else {
      output[i] = sign * postMultiplier;
    }
  }
}

this.constructDevice = () => constructPerChannelDevice({
  implementation: Overdrive125,
  inputs: {
    input: stereo('In'),
    pre: dbSetting('Pre-Gain', { defaultValue: 16, min: -24, max: 24 }),
    post: dbSetting('Post-Gain', { defaultValue: -3, min: -24, max: 24 })
  },
  outputs: {
    output: stereo('Out'),
  }
});
