double amplitudeDb = 20 * Math.log10(Math.abs(amplitude) / 32768);
I think maybe the problem is from Math.abs(amplitude) / 32768, amplitude is integer, so Math.abs(amplitude) will also return integer, as Math.abs(amplitude) is less than 32768 (perhaps I am not correct, byte is maximum 2^7 - 1, can here amplitude bigger than 32768? ). So Math.abs(amplitude) / 32768 is equal to 0. Log10(0) is -Infinity, I have tested with a Java project in Eclipse. You can change to
double amplitudeDb = 20 * Math.log10((double)Math.abs(amplitude) / 32768);