Java Code Examples for org.lwjgl.openal.AL10#alGetBufferi()
The following examples show how to use
org.lwjgl.openal.AL10#alGetBufferi() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenALStreamPlayer.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Poll the bufferNames - check if we need to fill the bufferNames with another * section. * * Most of the time this should be reasonably quick */ public synchronized void update() { if (done) { return; } int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED); while (processed > 0) { unqueued.clear(); AL10.alSourceUnqueueBuffers(source, unqueued); int bufferIndex = unqueued.get(0); int bufferLength = AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE); playedPos += bufferLength; if (musicLength > 0 && playedPos > musicLength) playedPos -= musicLength; if (stream(bufferIndex)) { AL10.alSourceQueueBuffers(source, unqueued); } else { remainingBufferCount--; if (remainingBufferCount == 0) { done = true; } } processed--; } int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE); if (state != AL10.AL_PLAYING) { AL10.alSourcePlay(source); } }
Example 2
Source File: OpenALStreamPlayer.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Poll the bufferNames - check if we need to fill the bufferNames with another * section. * * Most of the time this should be reasonably quick */ public synchronized void update() { if (done) { return; } int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED); while (processed > 0) { unqueued.clear(); AL10.alSourceUnqueueBuffers(source, unqueued); int bufferIndex = unqueued.get(0); int bufferLength = AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE); playedPos += bufferLength; if (musicLength > 0 && playedPos > musicLength) playedPos -= musicLength; if (stream(bufferIndex)) { AL10.alSourceQueueBuffers(source, unqueued); } else { remainingBufferCount--; if (remainingBufferCount == 0) { done = true; } } processed--; } int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE); if (state != AL10.AL_PLAYING) { AL10.alSourcePlay(source); } }
Example 3
Source File: AudioImpl.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create a new sound * * @param store The sound store from which the sound was created * @param buffer The buffer containing the sound data */ AudioImpl(SoundStore store, int buffer) { this.store = store; this.buffer = buffer; int bytes = AL10.alGetBufferi(buffer, AL10.AL_SIZE); int bits = AL10.alGetBufferi(buffer, AL10.AL_BITS); int channels = AL10.alGetBufferi(buffer, AL10.AL_CHANNELS); int freq = AL10.alGetBufferi(buffer, AL10.AL_FREQUENCY); int samples = bytes / (bits / 8); length = (samples / (float) freq) / channels; }
Example 4
Source File: OpenALStreamPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Poll the bufferNames - check if we need to fill the bufferNames with another * section. * * Most of the time this should be reasonably quick */ public void update() { if (done) { return; } float sampleRate = audio.getRate(); float sampleSize; if (audio.getChannels() > 1) { sampleSize = 4; // AL10.AL_FORMAT_STEREO16 } else { sampleSize = 2; // AL10.AL_FORMAT_MONO16 } int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED); while (processed > 0) { unqueued.clear(); AL10.alSourceUnqueueBuffers(source, unqueued); int bufferIndex = unqueued.get(0); float bufferLength = (AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE) / sampleSize) / sampleRate; positionOffset += bufferLength; if (stream(bufferIndex)) { AL10.alSourceQueueBuffers(source, unqueued); } else { remainingBufferCount--; if (remainingBufferCount == 0) { done = true; } } processed--; } int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE); if (state != AL10.AL_PLAYING) { AL10.alSourcePlay(source); } }