Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Linear volume response in VDR



Emil Naepflein wrote:
+     for (i = 1, Vol = 0; i < Volume; i++)
+        Vol += (256 - i) * (256 - i);
+
+     am.volume_left = am.volume_right = Vol / 21718;
A little math never hurts: This formula gives exactly the same result, but without a loop:

Vol = (393216 -1537*Volume +2*Volume*Volume) * (Volume-1) / 130308;

am.volume_left = am.volume_right = Vol;

This is a cubic equation satisfying the relation 1->1 and nearly 256->256, plus a gradient of 0 close to 256.

An alternate proposal would be:

Vol = Volume + (255*Volume - Volume*Volume)* q / 65025

Q is a free parameter in this quadratic variant. For q=0, this is the linear identity as before, and for q=255 this has a gradient of 0 at 255. All q=0..255 should work, and theres always 0->0 and 255->255.

Of course, if anyone knows what kind of non-linearity is behind the volume control, this would be even better.

Cheers,

Udo




Home | Main Index | Thread Index