Mar 19, 2016 at 6:34 PM
Edited Mar 19, 2016 at 6:46 PM
Simplest way is to decrease gain (attenuator). Increasing gain (amplificator) is not practical as you'll need to workaround clipping issues with samples values getting higher than 1.
Panning in analog equipment is usually done with a linear control (pot, fader...) sending voltage signal to VCA (voltage controlled attenuator).
See how the voltage signal (Y vol axis) is linear (V shaped) in this mono pan law graph:
The green signal is not a final gain value that you can easily apply to the samples values in DSP. The VCA here operates on a dB logarithmic scale, think exponential. The way to get out of the complex equations is to begin by converting the dB gain value to
a linear gain value.
For a typical pan law you convert ranges from [0, -3] dB to [1, 0] linear. You then apply that converted gain value to each sample with a linear convolution, fancy way of saying multiply sample value by constant value.
Stereo and other multi-channel pan laws brings summing operation in the mix, fancy way of saying add two sample values together. The only thing to watch out for is to never go over unity gain. If you sum two mono tracks to a single mono track without attenuation
you'll effectively create an amplificator and therefore risk clipping.
In this 2 tracks mixed to 1 scenario with a potential maximum sample value of 1 on each track, clipping happens because 1 + 1 > 1 so you can do 1 * 0.5 + 1 * 0.5 <= 1 to prevent clipping easily. The panning and mixing operations are done independently
in series on each sample value.