Java Code Examples for org.lwjgl.openal.AL10#alSourceStop()
The following examples show how to use
org.lwjgl.openal.AL10#alSourceStop() .
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: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOggStream(String ref) throws IOException { if (!soundWorks) { return new NullAudio(); } setMOD(null); setStream(null); if (currentMusic != -1) { AL10.alSourceStop(sources.get(0)); } getMusicSource(); currentMusic = sources.get(0); return new StreamSound(new OpenALStreamPlayer(currentMusic, ref)); }
Example 2
Source File: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Play the specified buffer as music (i.e. use the music channel) * * @param buffer The buffer to be played * @param pitch The pitch to play the music at * @param gain The gaing to play the music at * @param loop True if we should loop the music */ void playAsMusic(int buffer,float pitch,float gain, boolean loop) { paused = false; setMOD(null); if (soundWorks) { if (currentMusic != -1) { AL10.alSourceStop(sources.get(0)); } getMusicSource(); AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffer); AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch); AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE); currentMusic = sources.get(0); if (!music) { pauseLoop(); } else { AL10.alSourcePlay(sources.get(0)); } } }
Example 3
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOggStream(String ref) throws IOException { if (!soundWorks) { return new NullAudio(); } setMOD(null); setStream(null); if (currentMusic != -1) { AL10.alSourceStop(sources.get(0)); } getMusicSource(); currentMusic = sources.get(0); return new StreamSound(new OpenALStreamPlayer(currentMusic, ref)); }
Example 4
Source File: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOggStream(URL ref) throws IOException { if (!soundWorks) { return new NullAudio(); } setMOD(null); setStream(null); if (currentMusic != -1) { AL10.alSourceStop(sources.get(0)); } getMusicSource(); currentMusic = sources.get(0); return new StreamSound(new OpenALStreamPlayer(currentMusic, ref)); }
Example 5
Source File: AudioManager.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
public final void stopSources() { sound_play_counter--; if (sound_play_counter == 0) { for (int i = 0; i < sources.length; i++) { AudioSource source = sources[i]; int rank = source.getRank(); if (rank == AudioPlayer.AUDIO_RANK_MUSIC) { continue; } else if (rank == AudioPlayer.AUDIO_RANK_AMBIENT) { AL10.alSourcePause(sources[i].getSource()); } else { AL10.alSourceStop(sources[i].getSource()); } } } }
Example 6
Source File: OpenALStreamPlayer.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Start this stream playing * * @param loop True if the stream should loop * @throws IOException Indicates a failure to read from the stream */ public synchronized void play(boolean loop) throws IOException { this.loop = loop; initStreams(); done = false; AL10.alSourceStop(source); startPlayback(); syncStartTime = getTime(); }
Example 7
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Play the specified buffer as a sound effect with the specified * pitch and gain. * * @param buffer The ID of the buffer to play * @param pitch The pitch to play at * @param gain The gain to play at * @param loop True if the sound should loop * @param x The x position to play the sound from * @param y The y position to play the sound from * @param z The z position to play the sound from * @return source The source that will be used */ int playAsSoundAt(int buffer,float pitch,float gain,boolean loop,float x, float y, float z) { gain *= soundVolume; if (gain == 0) { gain = 0.001f; } if (soundWorks) { if (sounds) { int nextSource = findFreeSource(); if (nextSource == -1) { return -1; } AL10.alSourceStop(sources.get(nextSource)); AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer); AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch); AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain); AL10.alSourcei(sources.get(nextSource), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE); sourcePos.clear(); sourceVel.clear(); sourceVel.put(new float[] { 0, 0, 0 }); sourcePos.put(new float[] { x, y, z }); sourcePos.flip(); sourceVel.flip(); AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos); AL10.alSource(sources.get(nextSource), AL10.AL_VELOCITY, sourceVel); AL10.alSourcePlay(sources.get(nextSource)); return nextSource; } } return -1; }
Example 8
Source File: OpenALStreamPlayer.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Start this stream playing * * @param loop True if the stream should loop * @throws IOException Indicates a failure to read from the stream */ public synchronized void play(boolean loop) throws IOException { this.loop = loop; initStreams(); done = false; AL10.alSourceStop(source); startPlayback(); syncStartTime = getTime(); }
Example 9
Source File: OpenALStreamPlayer.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Clean up the buffers applied to the sound source */ private synchronized void removeBuffers() { AL10.alSourceStop(source); IntBuffer buffer = BufferUtils.createIntBuffer(1); while (AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED) > 0) { AL10.alSourceUnqueueBuffers(source, buffer); buffer.clear(); } }
Example 10
Source File: AbstractAudioPlayer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
public void stop() { if (playing) { AL10.alSourceStop(source.getSource()); AL10.alSourcei(source.getSource(), AL10.AL_BUFFER, AL10.AL_NONE); AL10.alSourceRewind(source.getSource()); playing = false; } }
Example 11
Source File: OpenALMODPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Play a mod or xm track streamed from the specified location * * @param module The moudle to play back * @param source The OpenAL source to play the music on * @param start True if the music should be started * @param loop True if the track should be looped */ public void play(Module module, int source, boolean loop, boolean start) { this.source = source; this.loop = loop; this.module = module; done = false; ibxm = new IBXM(48000); ibxm.set_module(module); songDuration = ibxm.calculate_song_duration(); if (bufferNames != null) { AL10.alSourceStop(source); bufferNames.flip(); AL10.alDeleteBuffers(bufferNames); } bufferNames = BufferUtils.createIntBuffer(2); AL10.alGenBuffers(bufferNames); remainingBufferCount = 2; for (int i=0;i<2;i++) { stream(bufferNames.get(i)); } AL10.alSourceQueueBuffers(source, bufferNames); AL10.alSourcef(source, AL10.AL_PITCH, 1.0f); AL10.alSourcef(source, AL10.AL_GAIN, 1.0f); if (start) { AL10.alSourcePlay(source); } }
Example 12
Source File: OpenALStreamPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Start this stream playing * * @param loop True if the stream should loop * @throws IOException Indicates a failure to read from the stream */ public void play(boolean loop) throws IOException { this.loop = loop; initStreams(); done = false; AL10.alSourceStop(source); removeBuffers(); startPlayback(); }
Example 13
Source File: MODSound.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Clean up the buffers applied to the sound source */ private void cleanUpSource() { AL10.alSourceStop(store.getSource(0)); IntBuffer buffer = BufferUtils.createIntBuffer(1); int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED); while (queued > 0) { AL10.alSourceUnqueueBuffers(store.getSource(0), buffer); queued--; } AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0); }
Example 14
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Play the specified buffer as a sound effect with the specified * pitch and gain. * * @param buffer The ID of the buffer to play * @param pitch The pitch to play at * @param gain The gain to play at * @param loop True if the sound should loop * @param x The x position to play the sound from * @param y The y position to play the sound from * @param z The z position to play the sound from * @return source The source that will be used */ int playAsSoundAt(int buffer,float pitch,float gain,boolean loop,float x, float y, float z) { gain *= soundVolume; if (gain == 0) { gain = 0.001f; } if (soundWorks) { if (sounds) { int nextSource = findFreeSource(); if (nextSource == -1) { return -1; } AL10.alSourceStop(sources.get(nextSource)); AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer); AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch); AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain); AL10.alSourcei(sources.get(nextSource), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE); sourcePos.clear(); sourceVel.clear(); sourceVel.put(new float[] { 0, 0, 0 }); sourcePos.put(new float[] { x, y, z }); sourcePos.flip(); sourceVel.flip(); AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos); AL10.alSource(sources.get(nextSource), AL10.AL_VELOCITY, sourceVel); AL10.alSourcePlay(sources.get(nextSource)); return nextSource; } } return -1; }
Example 15
Source File: OpenALStreamPlayer.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Clean up the buffers applied to the sound source */ private synchronized void removeBuffers() { AL10.alSourceStop(source); IntBuffer buffer = BufferUtils.createIntBuffer(1); while (AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED) > 0) { AL10.alSourceUnqueueBuffers(source, buffer); buffer.clear(); } }
Example 16
Source File: LwjglAL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alSourceStop(int source) { AL10.alSourceStop(source); }
Example 17
Source File: LwjglAL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alSourceStop(final int source) { AL10.alSourceStop(source); }
Example 18
Source File: MusicController.java From opsu with GNU General Public License v3.0 | 4 votes |
/** * Stops and releases all sources, clears each of the specified Audio * buffers, destroys the OpenAL context, and resets SoundStore for future use. * * Calling SoundStore.get().init() will re-initialize the OpenAL context * after a call to destroyOpenAL (Note: AudioLoader.getXXX calls init for you). * * @author davedes (http://slick.ninjacave.com/forum/viewtopic.php?t=3920) */ private static void destroyOpenAL() { if (!trackExists()) return; stop(); if (!AL.isCreated()) return; try { // get Music object's (private) Audio object reference Field sound = player.getClass().getDeclaredField("sound"); sound.setAccessible(true); Audio audio = (Audio) (sound.get(player)); // first clear the sources allocated by SoundStore int max = SoundStore.get().getSourceCount(); IntBuffer buf = BufferUtils.createIntBuffer(max); for (int i = 0; i < max; i++) { int source = SoundStore.get().getSource(i); buf.put(source); // stop and detach any buffers at this source AL10.alSourceStop(source); AL10.alSourcei(source, AL10.AL_BUFFER, 0); } buf.flip(); AL10.alDeleteSources(buf); int exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException( "Could not clear SoundStore sources, err: " + exc); } // delete any buffer data stored in memory, too... if (audio != null && audio.getBufferID() != 0) { buf = BufferUtils.createIntBuffer(1).put(audio.getBufferID()); buf.flip(); AL10.alDeleteBuffers(buf); exc = AL10.alGetError(); if (exc != AL10.AL_NO_ERROR) { throw new SlickException("Could not clear buffer " + audio.getBufferID() + ", err: "+exc); } } // clear OpenAL AL.destroy(); // reset SoundStore so that next time we create a Sound/Music, it will reinit SoundStore.get().clear(); player = null; } catch (Exception e) { ErrorHandler.error("Failed to destroy the OpenAL context.", e, true); } }
Example 19
Source File: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Stop a particular sound source * * @param index The index of the source to stop */ void stopSource(int index) { AL10.alSourceStop(sources.get(index)); }
Example 20
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 2 votes |
/** * Stop a particular sound source * * @param index The index of the source to stop */ void stopSource(int index) { AL10.alSourceStop(sources.get(index)); }