private static void writeToOutBuffer(ResampleContext rCtx, double f, int ch) {
        int s;
        if (rCtx.dstFloat) {
            rCtx.outBuffer.putFloat((float) f);
        } else {
            switch (rCtx.dbps) {
                case 1:
                    f *= 0x7f;
                    s = rCtx.dither > 0 ? do_shaping(rCtx, f, ch) : RINT(f);
                    rCtx.outBuffer.put((byte) (s + 128));
                    break;
                case 2:
                    f *= 0x7fff;
                    s = rCtx.dither > 0 ? do_shaping(rCtx, f, ch) : RINT(f);
                    rCtx.outBuffer.putShort((short) s);
                    break;
                case 3:
                    f *= 0x7fffff;
                    s = rCtx.dither > 0 ? do_shaping(rCtx, f, ch) : RINT(f);
                    rCtx.outBuffer.putShort((short) s);
                    s >>= 16;
                    rCtx.outBuffer.put((byte) s);
                    break;
            }
        }
    }