本文整理汇总了Java中org.lwjgl.BufferUtils.createShortBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.createShortBuffer方法的具体用法?Java BufferUtils.createShortBuffer怎么用?Java BufferUtils.createShortBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.BufferUtils
的用法示例。
在下文中一共展示了BufferUtils.createShortBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Decoder
import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
public Decoder(String path, IntBuffer buffers){
this.buffers = buffers;
vorbis = ResourceLoader.getBytes(path);
IntBuffer error = BufferUtils.createIntBuffer(1);
handle = stb_vorbis_open_memory(vorbis, error, null);
if(handle == 0L){
throw new RuntimeException("Unable to open stb");
}
STBVorbisInfo info = STBVorbisInfo.malloc();
stb_vorbis_get_info(handle, info);
channels = info.channels();
sampleRate = info.sample_rate();
format = (channels == 1) ? AL10.AL_FORMAT_MONO16 : AL10.AL_FORMAT_STEREO16;
lengthSamples = stb_vorbis_stream_length_in_samples(handle);
lengthSeconds = stb_vorbis_stream_length_in_seconds(handle);
pcm = BufferUtils.createShortBuffer(BUFFER_SIZE);
samplesLeft = lengthSamples;
}
示例2: allocate
import org.lwjgl.BufferUtils; //导入方法依赖的package包/类
private void allocate(){
ByteBuffer buffer = ResourceLoader.getBytes(path);
IntBuffer error = BufferUtils.createIntBuffer(1);
long decoder = stb_vorbis_open_memory(buffer, error, null);
if(decoder == 0L){
Application.error("Unable to open STB Vorbis");
return;
}
STBVorbisInfo info = STBVorbisInfo.malloc();
stb_vorbis_get_info(decoder, info);
int channels = info.channels();
int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples);
pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
stb_vorbis_close(decoder);
AL10.alBufferData(id, info.channels() == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate());
}