当前位置: 首页>>代码示例>>Java>>正文


Java ShortBuffer.hasRemaining方法代码示例

本文整理汇总了Java中java.nio.ShortBuffer.hasRemaining方法的典型用法代码示例。如果您正苦于以下问题:Java ShortBuffer.hasRemaining方法的具体用法?Java ShortBuffer.hasRemaining怎么用?Java ShortBuffer.hasRemaining使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ShortBuffer的用法示例。


在下文中一共展示了ShortBuffer.hasRemaining方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertAudioBytes

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * Convert the audio bytes into the stream
 * 
 * @param audio_bytes The audio byts
 * @param two_bytes_data True if we using double byte data
 * @return The byte bufer of data
 */
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data) {
	ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
	dest.order(ByteOrder.nativeOrder());
	ByteBuffer src = ByteBuffer.wrap(audio_bytes);
	src.order(ByteOrder.LITTLE_ENDIAN);
	if (two_bytes_data) {
		ShortBuffer dest_short = dest.asShortBuffer();
		ShortBuffer src_short = src.asShortBuffer();
		while (src_short.hasRemaining())
			dest_short.put(src_short.get());
	} else {
		while (src.hasRemaining())
			dest.put(src.get());
	}
	dest.rewind();
	return dest;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:25,代码来源:WaveData.java

示例2: convertAudioBytes

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * Convert the audio bytes into the stream
 * 
 * @param format The audio format being decoded
 * @param audio_bytes The audio byts
 * @param two_bytes_data True if we using double byte data
 * @return The byte bufer of data
 */
private static ByteBuffer convertAudioBytes(AudioFormat format, byte[] audio_bytes, boolean two_bytes_data) {
	ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
	dest.order(ByteOrder.nativeOrder());
	ByteBuffer src = ByteBuffer.wrap(audio_bytes);
	src.order(ByteOrder.BIG_ENDIAN);
	if (two_bytes_data) {
		ShortBuffer dest_short = dest.asShortBuffer();
		ShortBuffer src_short = src.asShortBuffer();
		while (src_short.hasRemaining())
			dest_short.put(src_short.get());
	} else {
		while (src.hasRemaining()) {
			byte b = src.get();
			if (format.getEncoding() == Encoding.PCM_SIGNED) {
				b = (byte) (b + 127);
			}
			dest.put(b);
		}
	}
	dest.rewind();
	return dest;
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:31,代码来源:AiffData.java

示例3: convertAudioBytes

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
 * Convert the audio bytes into the stream
 * 
 * @param audio_bytes
 *            The audio byts
 * @param two_bytes_data
 *            True if we using double byte data
 * @return The byte bufer of data
 */
private static ByteBuffer convertAudioBytes(byte[] audio_bytes,
		boolean two_bytes_data)
{
	ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
	dest.order(ByteOrder.nativeOrder());
	ByteBuffer src = ByteBuffer.wrap(audio_bytes);
	src.order(ByteOrder.LITTLE_ENDIAN);
	if (two_bytes_data)
	{
		ShortBuffer dest_short = dest.asShortBuffer();
		ShortBuffer src_short = src.asShortBuffer();
		while (src_short.hasRemaining())
			dest_short.put(src_short.get());
	}
	else
	{
		while (src.hasRemaining())
			dest.put(src.get());
	}
	dest.rewind();
	return dest;
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:32,代码来源:WaveData.java

示例4: convertAudioBytes

import java.nio.ShortBuffer; //导入方法依赖的package包/类
private static ByteBuffer convertAudioBytes(byte[] audio_bytes, boolean two_bytes_data, ByteOrder order) {
    ByteBuffer dest = ByteBuffer.allocateDirect(audio_bytes.length);
    dest.order(ByteOrder.nativeOrder());
    ByteBuffer src = ByteBuffer.wrap(audio_bytes);
    src.order(order);
    if (two_bytes_data) {
        ShortBuffer dest_short = dest.asShortBuffer();
        ShortBuffer src_short = src.asShortBuffer();
        while (src_short.hasRemaining())
            dest_short.put(src_short.get());
    } else {
        while (src.hasRemaining())
            dest.put(src.get());
    }
    dest.rewind();
    return dest;
}
 
开发者ID:TauOmicronMu,项目名称:TeamProject,代码行数:18,代码来源:WaveData.java

示例5: convertAudioBytes

import java.nio.ShortBuffer; //导入方法依赖的package包/类
/**
* Converts sound bytes to little-endian format.
* @param audio_bytes The original wave data
* @param two_bytes_data For stereo sounds.
* @return byte array containing the converted data.
*/
   @SuppressWarnings("unused") //Forge
   private static byte[] convertAudioBytes( byte[] audio_bytes,
                                            boolean two_bytes_data )
   {
       ByteBuffer dest = ByteBuffer.allocateDirect( audio_bytes.length );
       dest.order( ByteOrder.nativeOrder() );
       ByteBuffer src = ByteBuffer.wrap( audio_bytes );
       src.order( ByteOrder.LITTLE_ENDIAN );
       if( two_bytes_data )
       {
           ShortBuffer dest_short = dest.asShortBuffer();
           ShortBuffer src_short = src.asShortBuffer();
           while( src_short.hasRemaining() )
           {
               dest_short.put(src_short.get());
           }
       }
       else
       {
           while( src.hasRemaining() )
           {
               dest.put( src.get() );
           }
       }
       dest.rewind();

       if( !dest.hasArray() )
       {
           byte[] arrayBackedBuffer = new byte[dest.capacity()];
           dest.get( arrayBackedBuffer );
           dest.clear();

           return arrayBackedBuffer;
       }

       return dest.array();
   }
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:44,代码来源:CodecIBXM.java


注:本文中的java.nio.ShortBuffer.hasRemaining方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。