On Sun, Aug 12, 2012 at 3:07 PM, Fons Adriaensen <fons@linuxaudio.org> wrote:
it's just extremely clumsy to use a mixer that way, you'd need ten hands. For it means that whenever you want to adjust a single channnel you may have to adjust *all* others and the master at the same time.
Unlike humans, computers does not have a limited number of hands. This is not a priori a problem.
[1]
The first and sufficient argument is that is completely *unnecessary* to do such things.
Assume you have two or more apps producing sound, and one of them (A) has its volume set to max, so PA will set the master fader to max. Assume things are OK that way (which will probably be the case).
Things will still work well when (A) happens to contribute nothing (i.e. while it outputs silence). So things will still work well when (A) isn't there at all. *There is no need to change anything at all* when (A) goes away, even if all others have their volume set to lower values.
You have showed that it is unnecessary in one particular (very simple) case. However, you have not showed that it is unnecessary in all cases, so this is not really relevant (had we been talking about a human doing this, you'd have a point of course).
[2]
As to technical arguments, I can try. First thing to know is that you shouldn't confuse 'level' (a property of signal), and 'gain' (the ratio of two levels, or difference if you think in dB). Both are usually expressed in dB, but that doesn't make them the same thing. Compare it to time: a instant (epoch) and a duration are both expressed in the same units but they are different things. For example the sum of two epochs doesn't have any meaning, while the sum of two durations has. And if some activity has a duration of 40 minutes, that doesn't mean it has to finish at 00:40.
Similarly, if an apps has its gain set to -10 dB, that should not be taken to imply that it can't output more than -10 dB.
On 'real' mixers (digital or analog) you normally have considerable 'headroom'. Setting your master fader to -20 dB does not mean you can't output more than -20 dB. For digital ones that means that they use internally a wider format (more bits) than on the external interfaces. So you can actually trade off input gains and master gain to some extent.
Soundcard mixers are different. The PCM input to the mixer (i.e. the samples the SW provides) usually has the same format as the AD converter, e.g. 16 or 24 bits. That means that if the master is set to e.g. -20 dB, the card can't output any signal that is larger than -20 dB (w.r.t. its normal maximum level). Which is wrong. Assume you have two or more apps, all of them have their volume set to -20 dB.
This all makes sense. Thanks.
So PA will set the master output to -20 dB. Now even if all of these apps are limited to contributing -20 dB (but there is no reason why that should be), the sum of them can be higher, but your soundcard can't handle that.
That clearly would not work. Surely PA would need to adjust the master output to compensate for the number of channels? I don't know these implementation details, but I don't see how your arguments shows that this is impossible in general, just that the algorithm you outlined does not work.
[3]
On many soundcards the master fader also controls the level of things that PA or any software layer doesn't know about, e.g. and external mic input. Which you'd use for karaoke, or to hear yourself in your headphones while skyping. That level must not depend on how other apps set their volume controls. Again the software should not touch the master gain.
On soundcards where this is the case, then clearly this must be taken into account. However, that is not impossible. Either the information is given by ALSA, or a quirks table is needed. That does not mean that the general approach cannot work.
[4]
You can't apply a soundcard mixer gain change at some exact point in a sample stream. So you can't change the master gain and change your internal scaling to compensate at exactly the same time. There will always be a glitch.
Ok. This is what I was wondering about. I will try to listen for glitches then (I have not noticed any during my years of using PA, but I'll pay more attention). If it is true that a noticeable glitch is produced, then obviously you have a point, however if the glitch is not noticeable then I don't see the problem you have with PA. Clearly, PA is not meant for professional audio work. And it might be that for a professional all the PA logic is both unnecessary and maybe even detrimental (so you'd use jack or pure ALSA instead, that should not be a problem). However, that does not mean that PA is not a huge gain for the casual desktop user (assuming there are no bugs!). Thanks for the information. Tom