Java examples for javax.sound.sampled:Audio
bytes To Integers by Audio Format
//package com.java2s; import java.nio.ByteBuffer; import java.nio.ByteOrder; import javax.sound.sampled.AudioFormat; public class Main { public static void bytesToIntegers(AudioFormat format, byte[] source, int sourcePos, int sourceLen, int[] target, int targetPos) { if (format.getSampleSizeInBits() == 16) { ByteBuffer bb = ByteBuffer.wrap(source); if (format.isBigEndian()) bb.order(ByteOrder.BIG_ENDIAN); else/* w ww . j av a 2 s.com*/ bb.order(ByteOrder.LITTLE_ENDIAN); for (int i = 0; i < sourceLen / 2; i++) { target[i + targetPos] = bb.getShort(i * 2 + sourcePos); } } else if (format.getSampleSizeInBits() == 8) { for (int i = 0; i < sourceLen; i++) { target[i + targetPos] = source[i + sourcePos] * 256; } } } }