Beispiel #1
0
  private void setupSounds() throws Exception {
    SoundBuffer buffBack = new SoundBuffer("/sounds/background.ogg");
    soundMgr.addSoundBuffer(buffBack);
    SoundSource sourceBack = new SoundSource(true, true);
    sourceBack.setBuffer(buffBack.getBufferId());
    soundMgr.addSoundSource(Sounds.MUSIC.toString(), sourceBack);

    SoundBuffer buffBeep = new SoundBuffer("/sounds/beep.ogg");
    soundMgr.addSoundBuffer(buffBeep);
    SoundSource sourceBeep = new SoundSource(false, true);
    sourceBeep.setBuffer(buffBeep.getBufferId());
    soundMgr.addSoundSource(Sounds.BEEP.toString(), sourceBeep);

    SoundBuffer buffFire = new SoundBuffer("/sounds/fire.ogg");
    soundMgr.addSoundBuffer(buffFire);
    SoundSource sourceFire = new SoundSource(true, false);
    Vector3f pos = particleEmitter.getBaseParticle().getPosition();
    sourceFire.setPosition(pos);
    sourceFire.setBuffer(buffFire.getBufferId());
    soundMgr.addSoundSource(Sounds.FIRE.toString(), sourceFire);
    sourceFire.play();

    soundMgr.setListener(new SoundListener(new Vector3f(0, 0, 0)));

    sourceBack.play();
  }