@Override
    protected void onDataReceivedImpl(byte[] fft, int layersCount, float[] dBmArray, float[] ampArray) {
        // calculate dBs and amplitudes
        int dataSize = fft.length / 2 - 1;
        if (dbs == null || dbs.length != dataSize) {
            dbs = new float[dataSize];
        }
        if (allAmps == null || allAmps.length != dataSize) {
            allAmps = new float[dataSize];
        }
        for (int i = 0; i < dataSize; i++) {
            float re = fft[2 * i];
            float im = fft[2 * i + 1];
            float sqMag = re * re + im * im;
            dbs[i] = Utils.magnitudeToDb(sqMag);
            float k = 1;
            if (i == 0 || i == dataSize - 1) {
                k = 2;
            }
            allAmps[i] = (float) (k * Math.sqrt(sqMag) / dataSize);
        }
        for (int i = 0; i < layersCount; i++) {
            int index = (int) (coefficients[i] * fft.length);
            float db = dbs[index];
            float amp = allAmps[index];
            dBmArray[i] = db / MAX_DB_VALUE;
            ampArray[i] = amp;
        }
    }
Maximum value of dB. Used for controlling wave height percentage.
library/src/main/java/com/cleveroad/audiovisualization/VisualizerDbmHandler.java