Non Linear Volume (known issue) possible FIX

I haven’t looked at your code, but this worked great with the PCM5122 and non-linear volume problems on another project.

float volMap(long x, long in_min, long in_max, long out_min, long out_max) {
return ((float)x - (float)in_min) * ((float)out_max - (float)out_min) / ((float)in_max - (float)in_min) + (float)out_min;

long volumeDb = ((log10(volMap(value, 0, 255, 0, 1)))*126.0)+255;
if(volumeDb < 40){
volumeDb = 40;

This takes a linear scale of 0-255 and converts it into a logarithm scale from 40-255 (which is what the PCM5122 uses).

Hope this helps.

Hi ChiggerPepi,

that sounds interesting. In which file is the code to find?