I have two audio tracks (instrumental recordings) named track A, and track B. The tracks will be played in an application and the user of this application has the ability to change the balance of these tracks. The user controls a slider ranging from $x=0$ to $x=1$ with which the balance can be changed from hearing track A only, to hearing track A and B mixed equally, to hearing track B only. Mathematically, I have volume functions for track A and B, $V_A(x)$ and $V_B(x)$ respectively, that should satisfy:
- $V_A(0) = 1$
- $V_A(1) = 0$
- $V_A(0.5)=V_B(0.5)$
- $V_B(0) = 0$
- $V_B(1) = 1.$
The resulting track R is calculated as follows:
$R(t) = A(t) V_A(x) + B(t) V_B(x)$ where $0 \le x \le 1.$
A naive approach would be the to let $V_A(x) = 1 - x$ and $V_B(x) = x$ but I don't want the volume of track A to go down drastically as the user moves to the equal mix at $x = 0.5$. A better approach is $V_A(x) = \sqrt{1 - x}$ and $V_B(x) = \sqrt{x}$ (see How to mix two signals without changing the overall loudness?). But ideally, I would have the following function (with the non-constant parts possibly some other power function):
$V_A(x) = \left\{ \begin{array}{ll} 1 & \mbox{if } x \le 0.5 \\ 2 (1 - x) & \mbox{if } x > 0 \end{array} \right.$
$V_B(x) = \left\{ \begin{array}{ll} 2x & \mbox{if } x \le 0.5 \\ 1 & \mbox{if } x > 0.5 \end{array} \right.$
The problem is that both track A and track B are mastered at -0.1 dBFS (they will be played on a device and need to be as loud as possible), so obviously the last two functions will (most likely in my case) cause clipping.
I have two ideas on how to handle this:
- Use my ideal function and apply some type of limiter (or would it be better to limit track A and B first, and then mix?)
- Find the highest value for $V_A(0.5) = V_B(0.5)$ such that $R(t)$ never clips and then fill in the volume curve somehow. I can even limit some peaks so that this value could probably be quite high.
What are people's thoughts on this? My specific question is about idea 1. How does one go about creating a limiter? Does anyone have a good reference to some algorithms?