private static ByteBuffer toByteBuffer(byte[] data, boolean isStereo,
			boolean isBigEndian) {
		ByteBuffer dest = ByteBuffer.allocateDirect(data.length);
		dest.order(ByteOrder.nativeOrder());
		ByteBuffer src = ByteBuffer.wrap(data);
		src.order(isBigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN);
		if (isStereo) {
			ShortBuffer destAsShort = dest.asShortBuffer();
			ShortBuffer srcAsShort = src.asShortBuffer();
			while (srcAsShort.hasRemaining()) {
				destAsShort.put(srcAsShort.get());
			}
		} else {
			while (src.hasRemaining()) {
				dest.put(src.get());
			}
		}
		dest.rewind();
		return dest;
	}