Adjusting child volumes in propotion to master volume

41 Views Asked by At

I have a very fun problem, but I just cannot get it.

I have N number of child volume controls. And a master volume control:

All controls are range of 0 - 1.

The master volume = average of all child volumes.

Please try adjusting the child volumes in this fiddle here, it properly adjusts the master:

https://jsfiddle.net/Noitidart/4wcp4xkh/

My problem is I can't find a good formula to adjust the child sliders when the "Master Volume" slider is dragged. I can only solve the case where all child sliders are equal. May you please help?

1

There are 1 best solutions below

5
On

I think the only reasonable thing to do (which is annoying to calculate) is to maintain the same relative change in the child volumes as in the master volume.

Thus, if the master volume is dragged from $0.4$ to $0.41$, this is a change by a factor of $\frac{41}{40}$, so we should multiply all the other volumes by a factor of $\frac{41}{40}$.

This preserves the averaging thing, and is usually its own inverse (also a good property), but has a slight problem: suppose that one child volume is at $1$, when the others are at $0$, so that Master Volume is at $0.\overline{3}$. If we move Master Volume up, this suggests that we move the nonzero child volume up at $3$ times the rate; but how do we do that when it's already at maximum?

But it's not clear to me what you should do in that case; I think all approaches will have a problem here.


A simpler approach is to say that when the master volume is moved up or down by $\delta$, the child volumes each move up or down by $\delta$, unless some of them are at the limit and can't be changed further in that direction. In that case, the $k$ child volumes that can move in that direction do so, by $\frac3k \delta$.

I think that with actual volumes, this will result in the master volume making quiet child volumes disproportionately louder when increased. Also, when child volumes are pushed against their upper and lower bounds, reversing the action of the master volume doesn't return the child volumes to the same state.


Another completely different possibility is to decouple the values of the volume controls and have them only interact in the effect they have, as follows: if the master volume has value $v_m \in [0,1]$ and the child volumes have values $v_1, v_2, v_3 \in [0,1]$, have the actual volume of thing $i$ be proportional to the product $v_m v_i$. This has great behavior (and I think is what people do in practice) but might not be as transparent to the user.

And is not what you're asking about.