Java ByteBuffer to Float toFloat24BE(ByteBuffer buf, float[] out)

Here you can find the source of toFloat24BE(ByteBuffer buf, float[] out)

Description

to Float BE

License

BSD License

Declaration

private static int toFloat24BE(ByteBuffer buf, float[] out) 

Method Source Code

//package com.java2s;
/**/*from w  ww. ja v a2s .c o m*/
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author Jay Codec
 * 
 */

import java.nio.ByteBuffer;

public class Main {
    public final static float r24 = 1f / 8388608f;

    private static int toFloat24BE(ByteBuffer buf, float[] out) {
        int samples = 0;
        while (buf.remaining() >= 3 && samples < out.length) {
            out[samples++] = r24
                    * ((((buf.get() & 0xff) << 24) | ((buf.get() & 0xff) << 16) | ((buf.get() & 0xff) << 8)) >> 8);
        }
        return samples;
    }
}

Related

  1. toFloat(AudioFormat format, ByteBuffer buf, float[] floatBuf)
  2. toFloat(ByteBuffer buffer)
  3. toFloat(ByteBuffer bytes)
  4. toFloat(ByteBuffer value)
  5. toFloat16BE(ByteBuffer buf, FloatBuffer out)