Search in sources :

Example 1 with ALSoundSource

use of io.xol.chunkstories.sound.source.ALSoundSource in project chunkstories by Hugobros3.

the class ALSoundManager method playSoundEffect.

@Override
public SoundSource playSoundEffect(String soundEffect, Mode mode, Vector3dc position, float pitch, float gain, float attStart, float attEnd) {
    try {
        ALSoundSource ss;
        if (mode == Mode.STREAMED)
            ss = new ALBufferedSoundSource(soundEffect, position, pitch, gain, attStart, attEnd);
        else
            ss = new ALSoundSource(soundEffect, mode, position, pitch, gain, attStart, attEnd);
        addSoundSource(ss);
        return ss;
    } catch (SoundEffectNotFoundException e) {
        logger.warn("Sound not found " + soundEffect);
    }
    return new DummySoundSource();
}
Also used : DummySoundSource(io.xol.chunkstories.sound.source.DummySoundSource) ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource) SoundEffectNotFoundException(io.xol.chunkstories.api.exceptions.SoundEffectNotFoundException) ALBufferedSoundSource(io.xol.chunkstories.sound.source.ALBufferedSoundSource)

Example 2 with ALSoundSource

use of io.xol.chunkstories.sound.source.ALSoundSource in project chunkstories by Hugobros3.

the class ALSoundManager method stopAnySound.

@Override
public void stopAnySound(String sfx) {
    Iterator<ALSoundSource> i = playingSoundSources.iterator();
    while (i.hasNext()) {
        ALSoundSource soundSource = i.next();
        if (soundSource.soundData.getName().indexOf(sfx) != -1) {
            soundSource.stop();
            i.remove();
        }
    }
}
Also used : ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource)

Example 3 with ALSoundSource

use of io.xol.chunkstories.sound.source.ALSoundSource in project chunkstories by Hugobros3.

the class ALSoundManager method update.

public void update() {
    int result;
    if ((result = alGetError()) != AL_NO_ERROR)
        logger.error("error at iter :" + SoundDataOggSample.getALErrorString(result));
    removeUnplayingSources();
    Iterator<ALSoundSource> i = playingSoundSources.iterator();
    while (i.hasNext()) {
        ALSoundSource soundSource = i.next();
        soundSource.update(this);
    }
}
Also used : ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource)

Example 4 with ALSoundSource

use of io.xol.chunkstories.sound.source.ALSoundSource in project chunkstories by Hugobros3.

the class ALSoundManager method removeUnplayingSources.

int removeUnplayingSources() {
    int j = 0;
    Iterator<ALSoundSource> i = playingSoundSources.iterator();
    while (i.hasNext()) {
        SoundSource soundSource = i.next();
        if (soundSource.isDonePlaying()) {
            soundSource.stop();
            i.remove();
            j++;
        }
    }
    return j;
}
Also used : DummySoundSource(io.xol.chunkstories.sound.source.DummySoundSource) ALBufferedSoundSource(io.xol.chunkstories.sound.source.ALBufferedSoundSource) ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource) SoundSource(io.xol.chunkstories.api.sound.SoundSource) ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource)

Example 5 with ALSoundSource

use of io.xol.chunkstories.sound.source.ALSoundSource in project chunkstories by Hugobros3.

the class ALSoundManager method replicateServerSoundSource.

@Override
public SoundSource replicateServerSoundSource(String soundName, Mode mode, Vector3dc position, float pitch, float gain, float attenuationStart, float attenuationEnd, long UUID) {
    try {
        ALSoundSource soundSource = null;
        if (mode == Mode.STREAMED)
            soundSource = new ALBufferedSoundSource(soundName, position, pitch, gain, attenuationStart, attenuationEnd);
        else
            soundSource = new ALSoundSource(soundName, mode, position, pitch, gain, attenuationStart, attenuationEnd);
        // Match the UUIDs
        soundSource.setUUID(UUID);
        addSoundSource(soundSource);
        return soundSource;
    } catch (SoundEffectNotFoundException e) {
        logger.warn("Sound not found " + soundName);
        return null;
    }
}
Also used : ALSoundSource(io.xol.chunkstories.sound.source.ALSoundSource) SoundEffectNotFoundException(io.xol.chunkstories.api.exceptions.SoundEffectNotFoundException) ALBufferedSoundSource(io.xol.chunkstories.sound.source.ALBufferedSoundSource)

Aggregations

ALSoundSource (io.xol.chunkstories.sound.source.ALSoundSource)5 ALBufferedSoundSource (io.xol.chunkstories.sound.source.ALBufferedSoundSource)3 SoundEffectNotFoundException (io.xol.chunkstories.api.exceptions.SoundEffectNotFoundException)2 DummySoundSource (io.xol.chunkstories.sound.source.DummySoundSource)2 SoundSource (io.xol.chunkstories.api.sound.SoundSource)1