Java 类org.lwjgl.openal.AL10 实例源码

项目:featurea    文件:MusicControllerImpl.java   
public synchronized void update() {
    if (sourceID == -1) return;
    boolean end = false;
    int buffers = AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_PROCESSED);
    while (buffers-- > 0) {
        int bufferID = AL10.alSourceUnqueueBuffers(sourceID);
        if (bufferID == AL10.AL_INVALID_VALUE) break;
        renderedSeconds += secondsPerBuffer;
        if (end) continue;
        if (fill(bufferID)) {
            AL10.alSourceQueueBuffers(sourceID, bufferID);
        } else {
            end = true;
        }
    }
    if (end && AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_QUEUED) == 0) {
        stop();
    }
    if (isPlaying && AL10.alGetSourcei(sourceID, AL10.AL_SOURCE_STATE) != AL10.AL_PLAYING)
        AL10.alSourcePlay(sourceID);
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * 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)); 
        }
    }
}
项目:Towan    文件:SoundStore.java   
/**
 * 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));
}
项目:BaseClient    文件:StreamSound.java   
/**
 * Clean up the buffers applied to the sound source
 */
private void cleanUpSource() {
    SoundStore store = SoundStore.get();

    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);
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * 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));
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * 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));
}
项目:Towan    文件:OpenALMODPlayer.java   
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
    try {
    AL.create();
    soundWorks = true;
} catch (LWJGLException e) {
    System.err.println("Failed to initialise LWJGL OpenAL");
    soundWorks = false;
    return;
}

if (soundWorks) {
    IntBuffer sources = BufferUtils.createIntBuffer(1);
    AL10.alGenSources(sources);

    if (AL10.alGetError() != AL10.AL_NO_ERROR) {
        System.err.println("Failed to create sources");
        soundWorks = false;
    } else {
        source = sources.get(0);
    }

}
  }
项目:Towan    文件:StreamSound.java   
/**
 * Clean up the buffers applied to the sound source
 */
private void cleanUpSource() {
    SoundStore store = SoundStore.get();

    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);
}
项目:Progetto-C    文件:SoundStore.java   
/**
 * 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));
}
项目:BaseClient    文件:SoundStore.java   
/**
 * 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));
}
项目:LD38    文件:Listener.java   
public void setOrientation(Vector3f orientation){
    if(this.orientation.equals(orientation)){
        return;
    }

    oriBuffer.clear();
    oriBuffer.put(new float[]{
            0f,1f,0f,
            orientation.x,
            orientation.y,
            orientation.z
    });
    oriBuffer.flip();

    this.orientation.set(orientation);

    AL10.alListenerfv(AL10.AL_ORIENTATION, oriBuffer);
}
项目:Sound-Physics    文件:SoundPhysics.java   
private static void setEnvironment(int sourceID, float sendGain0, float sendGain1, float sendGain2, float sendGain3, float sendCutoff0, float sendCutoff1,
        float sendCutoff2, float sendCutoff3, float directCutoff, float directGain)
{
    //Set reverb send filter values and set source to send to all reverb fx slots
    EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAIN, sendGain0);
    EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAINHF, sendCutoff0);
    AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot0, 0, sendFilter0);  

    EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAIN, sendGain1);
    EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAINHF, sendCutoff1);
    AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot1, 1, sendFilter1);  

    EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAIN, sendGain2);
    EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAINHF, sendCutoff2);
    AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot2, 2, sendFilter2);  

    EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAIN, sendGain3);
    EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAINHF, sendCutoff3);
    AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot3, 3, sendFilter3);  

    EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAIN, directGain);
    EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAINHF, directCutoff);
    AL10.alSourcei(sourceID, EFX10.AL_DIRECT_FILTER, directFilter0);

    AL10.alSourcef(sourceID, EFX10.AL_AIR_ABSORPTION_FACTOR, SoundPhysicsCore.Config.airAbsorption);
}
项目:LD38    文件:Sound.java   
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());
}
项目:Towan    文件:SoundStore.java   
/**
 * 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));
}
项目:BaseClient    文件:SoundStore.java   
/**
 * 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)); 
        }
    }
}
项目:trashjam2017    文件:OpenALStreamPlayer.java   
/**
 * Create a new player to work on an audio stream
 * 
 * @param source The source on which we'll play the audio
 * @param ref A reference to the audio file to stream
 */
public OpenALStreamPlayer(int source, String ref) {
    this.source = source;
    this.ref = ref;

    bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT);
    AL10.alGenBuffers(bufferNames);
}
项目:trashjam2017    文件:OpenALStreamPlayer.java   
/**
 * Create a new player to work on an audio stream
 * 
 * @param source The source on which we'll play the audio
 * @param url A reference to the audio file to stream
 */
public OpenALStreamPlayer(int source, URL url) {
    this.source = source;
    this.url = url;

    bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT);
    AL10.alGenBuffers(bufferNames);
}
项目:trashjam2017    文件:OpenALStreamPlayer.java   
/**
 * Clean up the buffers applied to the sound source
 */
private void removeBuffers() {
    IntBuffer buffer = BufferUtils.createIntBuffer(1);
    int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);

    while (queued > 0)
    {
        AL10.alSourceUnqueueBuffers(source, buffer);
        queued--;
    }
}
项目:trashjam2017    文件:OpenALStreamPlayer.java   
/**
 * 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();
}
项目:featurea    文件:OpenALImpl.java   
@Override
public void destroy() {
    try {
        if (AL.isCreated()) {
            for (int i = 0; i < music.size(); i++) {
                MusicController musicControllerImpl = music.get(i);
                if (musicControllerImpl != null) {
                    musicControllerImpl.release();
                }
            }
            for (int i = 0, n = allSources.size; i < n; i++) {
                int sourceID = allSources.get(i);
                int state = AL10.alGetSourcei(sourceID, AL10.AL_SOURCE_STATE);
                if (state != AL10.AL_STOPPED) AL10.alSourceStop(sourceID);
                AL10.alDeleteSources(sourceID);
            }
            sourceToSoundId.clear();
            soundIdToSource.clear();
            AL.destroy();
            while (AL.isCreated()) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException skip) {
                    skip.printStackTrace();
                }
            }
        }
    } catch (UnsatisfiedLinkError e) {
        e.printStackTrace();
    }
}
项目:featurea    文件:OpenALImpl.java   
public void setSoundLooping(long soundId, boolean looping) {
    if (AL.isCreated()) {
        if (soundIdToSource.containsKey(soundId)) {
            int sourceId = soundIdToSource.get(soundId);
            AL10.alSourcei(sourceId, AL10.AL_LOOPING, looping ? AL10.AL_TRUE : AL10.AL_FALSE);
        }
    }
}
项目:trashjam2017    文件:AudioImpl.java   
/**
 * 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;
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * Set the music volume of the current playing music. Does NOT affect the global volume
 * 
 * @param volume The volume for the current playing music
 */
public void setCurrentMusicVolume(float volume) {
    if (volume < 0) {
        volume = 0;
    }
    if (volume > 1) {
        volume = 1;
    }

    if (soundWorks) {
        lastCurrentMusicVolume = volume;
        AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); 
    }
}
项目:Towan    文件:SoundStore.java   
/**
 * Set the music volume of the current playing music. Does NOT affect the global volume
 * 
 * @param volume The volume for the current playing music
 */
public void setCurrentMusicVolume(float volume) {
    if (volume < 0) {
        volume = 0;
    }
    if (volume > 1) {
        volume = 1;
    }

    if (soundWorks) {
        lastCurrentMusicVolume = volume;
        AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); 
    }
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * 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;
}
项目:BaseClient    文件:SoundStore.java   
/**
 * Restart the music loop that is currently paused
 */
public void restartLoop() {
    if ((music) && (soundWorks) && (currentMusic != -1)){
        paused = false;
        AL10.alSourcePlay(currentMusic);
    }
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * Pause the music loop that is currently playing
 */
public void pauseLoop() {
    if ((soundWorks) && (currentMusic != -1)){
        paused = true;
        AL10.alSourcePause(currentMusic);
    }
}
项目:Towan    文件:OpenALStreamPlayer.java   
/**
 * Starts the streaming.
 */
private void startPlayback() {
    AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE);
    AL10.alSourcef(source, AL10.AL_PITCH, pitch);

    remainingBufferCount = BUFFER_COUNT;

    for (int i = 0; i < BUFFER_COUNT; i++) {
        stream(bufferNames.get(i));
    }

    AL10.alSourceQueueBuffers(source, bufferNames);
    AL10.alSourcePlay(source);
}
项目:trashjam2017    文件:SoundStore.java   
/**
 * Check if the music is currently playing
 * 
 * @return True if the music is playing
 */
public boolean isMusicPlaying() 
{
    if (!soundWorks) {
        return false;
    }

    int state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
    return ((state == AL10.AL_PLAYING) || (state == AL10.AL_PAUSED));
}
项目:trashjam2017    文件:MODSound.java   
/**
 * 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);
}
项目:featurea    文件:OpenALImpl.java   
public void stopSound(long soundId) {
    if (AL.isCreated()) {
        if (soundIdToSource.containsKey(soundId)) {
            int sourceId = soundIdToSource.get(soundId);
            AL10.alSourceStop(sourceId);
        }
    }
}
项目:Towan    文件:AudioImpl.java   
/**
 * 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;
}
项目:Progetto-C    文件:OpenALStreamPlayer.java   
/**
 * Create a new player to work on an audio stream
 * 
 * @param source The source on which we'll play the audio
 * @param url A reference to the audio file to stream
 */
public OpenALStreamPlayer(int source, URL url) {
    this.source = source;
    this.url = url;

    bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT);
    AL10.alGenBuffers(bufferNames);
}
项目:Progetto-C    文件:OpenALStreamPlayer.java   
/**
 * Clean up the buffers applied to the sound source
 */
private void removeBuffers() {
    IntBuffer buffer = BufferUtils.createIntBuffer(1);
    int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);

    while (queued > 0)
    {
        AL10.alSourceUnqueueBuffers(source, buffer);
        queued--;
    }
}
项目:featurea    文件:OpenALImpl.java   
public void pauseSourcesWithBuffer(int bufferID) {
    if (AL.isCreated()) {
        for (int i = 0, n = idleSources.size; i < n; i++) {
            int sourceID = idleSources.get(i);
            if (AL10.alGetSourcei(sourceID, AL10.AL_BUFFER) == bufferID) {
                AL10.alSourcePause(sourceID);
            }
        }
    }
}
项目:Progetto-C    文件:AudioImpl.java   
/**
 * 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;
}
项目:Progetto-C    文件:AudioImpl.java   
/**
 * @see org.newdawn.slick.openal.Audio#setPosition(float)
 */
public boolean setPosition(float position) {
    position = position % length;

    AL10.alSourcef(store.getSource(index), AL11.AL_SEC_OFFSET, position);
    if (AL10.alGetError() != 0) {
        return false;
    }
    return true;
}
项目:Progetto-C    文件:SoundStore.java   
/**
 * Set the music volume
 * 
 * @param volume The volume for music
 */
public void setMusicVolume(float volume) {
    if (volume < 0) {
        volume = 0;
    }
    if (volume > 1) {
        volume = 1;
    }

    musicVolume = volume;
    if (soundWorks) {
        AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); 
    }
}
项目:Progetto-C    文件:SoundStore.java   
/**
 * Set the music volume of the current playing music. Does NOT affect the global volume
 * 
 * @param volume The volume for the current playing music
 */
public void setCurrentMusicVolume(float volume) {
    if (volume < 0) {
        volume = 0;
    }
    if (volume > 1) {
        volume = 1;
    }

    if (soundWorks) {
        lastCurrentMusicVolume = volume;
        AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); 
    }
}
项目:BaseClient    文件:MODSound.java   
/**
 * 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);
}