HydrogenAudio

Hydrogenaudio Forum => General Audio => Topic started by: goodsound on 2006-03-01 17:30:19

Title: How does software volume control work ?
Post by: goodsound on 2006-03-01 17:30:19
How exactly does software (windows mixer, players like foobar, etc..) volume control work ? Is it the equivalent of replay gain or normalizing ? or is it more "electronic" or "hardware" than that ?
Thanks.
Title: How does software volume control work ?
Post by: Shade[ST] on 2006-03-01 17:37:18
It can be approximated by normalizing.  No analysis is performed on sound to determine percieved loudness;  It simply multiplies the played back samples by a constant number.
Title: How does software volume control work ?
Post by: gasmann on 2006-03-01 17:38:39
It depends. Windows Mixer and most players use the sound drivers implementation for setting the volume.
Foobar2000 does it on it's own - it scales the output before sending it to the driver, and is thereby not using the sound drivers implementation. However, it depends on it too since the data sent to the driver by foobar will be output to speakers/headphones etc. at the sound drivers volume setting. So in this case it's like two mixers in a chain.

And no, it doesn't have anything to do with rg or normalizing in this case. Normalizing means scaling the waverform so that the peak is at or very near 100% (-0dB), and RG means making all tracks/albums have the same overall loudness.
Title: How does software volume control work ?
Post by: Shade[ST] on 2006-03-01 18:09:25
You don't have to normalize to a specified level.  Normalization only involves multiplying a statistic set by a constant number.

http://en.wikipedia.org/wiki/Audio_normalization (http://en.wikipedia.org/wiki/Audio_normalization)
Title: How does software volume control work ?
Post by: saratoga on 2006-03-01 18:20:51
In addition to scaling the samples, some software (Ipod OS for instance) controls the output power level on the audio hardware.
Title: How does software volume control work ?
Post by: goodsound on 2006-03-01 19:11:04
but what exactly happens when "scaling" ? I am asking about the implementation details. For example, normalizing works by adding bits to the actual sample(right?). Likewise what does scaling do ?
Title: How does software volume control work ?
Post by: Fandango on 2006-03-01 19:42:07
What bothers me all the time is that there is very rarely any values shown of how much the volume is changed. At most we get a slider, that's all. No percent scale is shown, you have to "guess" it with your eyes or count the marks, steps on the slider, which is either no guarentee that you will set the volume to a specific level or very cumbersome to hit the cursor keys 20-40 times every time you or worse an application has changed the driver volume settings. This is too old-way analog for me, using a slider. I want to be able to set the volume more precisely, or at best lock them, so that no program can change them on their own (Real Player/Plugin).

The only mixer control programs that I remember that let the user do this were made for Linux/BSD type systems. There were many of them because it was as easy as opening a file (/dev/mixer) to manipulate the drivers settings.
Title: How does software volume control work ?
Post by: AndyH-ha on 2006-03-01 20:09:24
Quote
normalizing works by adding bits to the actual sample(right?)
No, no bits are ever added or subtracted. Each sample is a number, a signal level measurement, normally expressed in dB for convenience. That value is modified, increased or decreased, so the new value (the new signal level) is closer to, or further from, 0dB.

As you decrease the volume level, sample values decrease below the minimum supported (e.g. aprox -96dB for sixteen bit files) so you are effectively decreasing the bit depth.
Title: How does software volume control work ?
Post by: goodsound on 2006-03-01 21:07:09
If I understand correctly, the software volume control acutally only 'reduces' the volume - from 0 to -96. It cannot 'increase' it.

So at max volume level the actual sample value is used, and at say 50% volume the actual sample value is divided by 2 before its passed on ?
Am I thinking this through correctly ? If this is correct then does this messing around with the actual/real sample value in any way affect the sound ?
I'd imagine not, but....
Title: How does software volume control work ?
Post by: Shade[ST] on 2006-03-01 21:14:08
Quote
If I understand correctly, the software volume control acutally only 'reduces' the volume - from 0 to -96. It cannot 'increase' it.

So at max volume level the actual sample value is used, and at say 50% volume the actual sample value is divided by 2 before its passed on ?
Am I thinking this through correctly ? If this is correct then does this messing around with the actual/real sample value in any way affect the sound ?

That's approximately it.  However, some badly programmed drivers cannot treat sample values that go over a certain point, and that's why you can have clipping when above a certain volume setting in the windows mixer.

eg : say you have a sample value that goes from -32768 to 32767; the volume control will multiply the sample by a number between 0 and 1, and then truncates it.  Eg :

a sample at 345 with volume at 50 % (0.5) will be down to 172 after volume setting.

Now let's say that a sound driver can't play samples if they're above, say.. 30000.  Some music will clip (all values above 30000 will be brought to that number), and the playback will sound worse.
Title: How does software volume control work ?
Post by: goodsound on 2006-03-01 22:16:55
Quote
.and then truncates it.

dang..I was afraid of that! Atleast theoritically all that rounding/truncating will skew the resulting waveform. It won't really be a half-size 'image' of the original. Not sure if this results into any perceivable distortion. Does it ?
Title: How does software volume control work ?
Post by: Shade[ST] on 2006-03-01 22:27:00
If there is no clipping, the truncating and / or rounding should not be detectable to human ears.  It's less than 0.01 db volume amplitude change.