The UPnP Media Renderer
UPnP Media Renderer's software implementation
RenderingControl (cont'd)
I also want to say something about the encodeVolume and decodeVolume methods. These are two private methods which try to correct the behaviour of the volume scale. In fact I noticed that the volume scale of the PCM channel onto the Raspberry Pi was not linear, in particular the volume was very low in the first portion of the volume scale. So, I decided to find a way to improve the volume by amplifying and stretching the scale.
The problem formulation was this:
"Given the equation y = m * (x / a) + q, where x is the volume value set by the user, y is the new volume value (encoded value), a is the stretching factor and m is equal to 1, we want to find a and q in order to have y = 60 when x = 5 and y = 100 when x = 100."
So, by solving a simple linear system of two equations we find that a = 2.375 and q ≅ 57.89. The encodeVolume method implements this function, instead the decodeVolume method implements the inverse function (necessary to restore the right value on the volume scale seen by the user). This solution works fine for our purposes but surely there will be a more precise solution for this issue.