本文整理匯總了Java中org.lwjgl.openal.AL10.alBufferData方法的典型用法代碼示例。如果您正苦於以下問題:Java AL10.alBufferData方法的具體用法?Java AL10.alBufferData怎麽用?Java AL10.alBufferData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.openal.AL10
的用法示例。
在下文中一共展示了AL10.alBufferData方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: allocate
import org.lwjgl.openal.AL10; //導入方法依賴的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());
}
示例2: fill
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
private boolean fill(int bufferID) {
tempBuffer.clear();
int length = read(tempBytes);
if (length <= 0) {
if (isLoop) {
reset();
renderedSeconds = 0;
length = read(tempBytes);
if (length <= 0) return false;
} else {
return false;
}
}
tempBuffer.put(tempBytes, 0, length).flip();
AL10.alBufferData(bufferID, format, tempBuffer, sampleRate);
return true;
}
示例3: stream
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Stream one section from the mod/xm into an OpenAL buffer
*
* @param bufferId The ID of the buffer to fill
* @return True if another section was available
*/
public boolean stream(int bufferId) {
int frames = sectionSize;
boolean reset = false;
boolean more = true;
if (frames > songDuration) {
frames = songDuration;
reset = true;
}
ibxm.get_audio(data, frames);
bufferData.clear();
bufferData.put(data);
bufferData.limit(frames * 4);
if (reset) {
if (loop) {
ibxm.seek(0);
ibxm.set_module(module);
songDuration = ibxm.calculate_song_duration();
} else {
more = false;
songDuration -= frames;
}
} else {
songDuration -= frames;
}
bufferData.flip();
AL10.alBufferData(bufferId, AL10.AL_FORMAT_STEREO16, bufferData, 48000);
return more;
}
示例4: setup
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
protected void setup(byte[] pcm, int channels, int sampleRate) {
int bytes = pcm.length - (pcm.length % (channels > 1 ? 4 : 2));
int samples = bytes / (2 * channels);
duration = samples / (double) sampleRate;
ByteBuffer buffer = (ByteBuffer) BufferUtils.createByteBuffer(bytes).put(pcm, 0, bytes).flip();
if (bufferID == -1) {
bufferID = AL10.alGenBuffers(); // Failed to flush core dump. Minidumps are not enabled by default on client versions of Windows
AL10.alBufferData(bufferID, channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, buffer.asShortBuffer(), sampleRate);
}
}
示例5: getWAV
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Get the Sound based on a specified WAV file
*
* @param ref The reference to the WAV file in the classpath
* @param in The stream to the WAV to load
* @return The Sound read from the WAV file
* @throws IOException Indicates a failure to load the WAV
*/
public Audio getWAV(String ref, InputStream in) throws IOException {
if (!soundWorks) {
return new NullAudio();
}
if (!inited) {
throw new RuntimeException("Can't load sounds until SoundStore is init(). Use the container init() method.");
}
if (deferred) {
return new DeferredSound(ref, in, DeferredSound.WAV);
}
int buffer = -1;
if (loaded.get(ref) != null) {
buffer = ((Integer) loaded.get(ref)).intValue();
} else {
try {
IntBuffer buf = BufferUtils.createIntBuffer(1);
WaveData data = WaveData.create(in);
AL10.alGenBuffers(buf);
AL10.alBufferData(buf.get(0), data.format, data.data, data.samplerate);
loaded.put(ref,new Integer(buf.get(0)));
buffer = buf.get(0);
} catch (Exception e) {
Log.error(e);
IOException x = new IOException("Failed to load: "+ref);
x.initCause(e);
throw x;
}
}
if (buffer == -1) {
throw new IOException("Unable to load: "+ref);
}
return new AudioImpl(this, buffer);
}
示例6: getOgg
import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
* Get the Sound based on a specified OGG file
*
* @param ref The reference to the OGG file in the classpath
* @param in The stream to the OGG to load
* @return The Sound read from the OGG file
* @throws IOException Indicates a failure to load the OGG
*/
public Audio getOgg(String ref, InputStream in) throws IOException {
if (!soundWorks) {
return new NullAudio();
}
if (!inited) {
throw new RuntimeException("Can't load sounds until SoundStore is init(). Use the container init() method.");
}
if (deferred) {
return new DeferredSound(ref, in, DeferredSound.OGG);
}
int buffer = -1;
if (loaded.get(ref) != null) {
buffer = ((Integer) loaded.get(ref)).intValue();
} else {
try {
IntBuffer buf = BufferUtils.createIntBuffer(1);
OggDecoder decoder = new OggDecoder();
OggData ogg = decoder.getData(in);
AL10.alGenBuffers(buf);
AL10.alBufferData(buf.get(0), ogg.channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, ogg.data, ogg.rate);
loaded.put(ref,new Integer(buf.get(0)));
buffer = buf.get(0);
} catch (Exception e) {
Log.error(e);
Sys.alert("Error","Failed to load: "+ref+" - "+e.getMessage());
throw new IOException("Unable to load: "+ref);
}
}
if (buffer == -1) {
throw new IOException("Unable to load: "+ref);
}
return new AudioImpl(this, buffer);
}