Audio-Programming: Directshow Logarithmic Volume Control

[Latexpage]When programming audio user-interfaces, volume is usually calculated in form of logarithmic scales. In Windows, specifically DirectX, volume ranges from -10000 (=silence) up to 0 (=maximum volume). However, a volume slide is moved linearly between e.g. 0 (=silence) up to 1.0 (maximum volume) - so we need to convert linear values to logarithmic and vice versa.

The basic function, that takes a linear value in the range of [0;1] and converts to a exponential value can be denoted as:

exp10-volume1 
Note, that this function ranges from 0 up to 10 on the vertical axis. The inverse function can be denoted as the logarithmic function with base 10:

exp10-volume2

In order to apply the correct ranges, we need to shift the values of x in both functions. Thus, we can rewrite $f(x)$ as:

exp10-volume3For the logarithmic function, we write:

exp10-volume4
Using these formulae, we can convert volumes within the linear ranges from 0.0 to 1.0 to logarithmic values between -10000 and 0 and vice versa.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.