private float getFloat(byte[] b) {
        float sample = 0.0f;
        int ret = 0;
        int length = b.length;
        for (int i = 0; i < b.length; i++, length--) {
            ret |= ((int) (b[i] & 0xFF) << ((((bigEndian) ? length : (i + 1)) * 8) - 8));
        }
        switch (bits) {
            case 1:
                if (ret > 0x7F) {
                    ret = ~ret + 1;
                    ret &= 0x7F;
                    ret = ~ret + 1;
                }
                sample = (float) ((float) ret / (float) Byte.MAX_VALUE);
                break;
            case 2:
                if (ret > 0x7FFF) {
                    ret = ~ret + 1;
                    ret &= 0x7FFF;
                    ret = ~ret + 1;
                }
                sample = (float) ((float) ret / (float) Short.MAX_VALUE);
                break;
            case 3:
                if (ret > 0x7FFFFF) {
                    ret = ~ret + 1;
                    ret &= 0x7FFFFF;
                    ret = ~ret + 1;
                }
                sample = (float) ((float) ret / 8388608f);
                break;
            case 4:
                sample = (float) ((float) ret / (float) Integer.MAX_VALUE);
                break;
            default:
                System.err.println("Format not accepted");
        }
        return sample;
    }