/** * 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)); } } }
/** * 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)); }