Mailing List archive

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

[vdr] Re: Linear volume response in VDR



On Sonntag, 17. Oktober 2004 11:10, Klaus Schmidinger wrote:
> Udo Richter wrote:
> > 
> > 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.
> 
> Thanks for the explanation.
> I think I'll go with the last formula, with q = 255.
> However, shouldn't the rightmost contant be 65535 (0xFFFF)?
> It doesn't make much difference, actually, but I'm having a hard
> time understanding 65025, while 65535 would seem natural...

65025 = 255*255

This value results from the design criterium
gradient=0 for q=255 and Volume=255.

Obvioulsly, the formula can be simplified for q=255:
Vol = Volume + (255*Volume - Volume*Volume) * 255 / (255*255)
Vol = Volume + (255*Volume - Volume*Volume) / 255
Vol = 2*Volume - Volume*Volume/255

Oliver

-- 
--------------------------------------------------------
VDR Remote Plugin available at
http://endriss.escape.bei.t-online.de/vdr/
--------------------------------------------------------




Home | Main Index | Thread Index