コード例 #1
0
  public void initAudio() {
    audioMgr = AudioManagerFactory.createAudioManager("sage.audio.joal.JOALAudioManager");
    if (!audioMgr.initialize()) {
      System.out.println("Audio Manager failed to initialize!");
      return;
    }
    resource1 =
        audioMgr.createAudioResource(
            "src/sounds/Kai_Engel_-_07_-_February.wav", AudioResourceType.AUDIO_SAMPLE);
    // resource1 = audioMgr.createAudioResource("src/12345.wav",
    // AudioResourceType.AUDIO_SAMPLE);
    // System.out.println(resource1.getIsLoaded());
    // System.out.println(resource1.getAudioFormat());
    // System.out.println(resource1.getFileName());
    // System.out.println(resource1.getAudioType());
    backgroundMusic = new Sound(resource1, SoundType.SOUND_EFFECT, 100, true);
    backgroundMusic.initialize(audioMgr);

    backgroundMusic.setMaxDistance(50.0f);
    backgroundMusic.setMinDistance(3.0f);
    backgroundMusic.setRollOff(5.0f);
    backgroundMusic.setLocation(new Point3D(player1.getWorldTranslation().getCol(3)));

    setEarParameters();
    // musicSound.play();
    backgroundMusic.play();

    resource1 =
        audioMgr.createAudioResource(
            "src/sounds/Splat-SoundBible.wav", AudioResourceType.AUDIO_SAMPLE);
    splatSound = new Sound(resource1, SoundType.SOUND_EFFECT, 100, true);
    splatSound.initialize(audioMgr);

    splatSound.setMaxDistance(50.0f);
    splatSound.setMinDistance(3.0f);
    splatSound.setRollOff(5.0f);
    splatSound.setLocation(new Point3D(player1.getWorldTranslation().getCol(3)));
  }
コード例 #2
0
  public void setEarParameters() {
    Matrix3D avDir = (Matrix3D) (player1.getWorldRotation().clone());
    float camAz;

    if (!isGPOn) {
      camAz = cam1Controller.getAzimuth();
    } else {
      camAz = cam1GPController.getAzimuth();
    }

    avDir.rotateY(180.0f - camAz);
    Vector3D camDir = new Vector3D(0, 0, 1);
    camDir = camDir.mult(avDir);
    audioMgr.getEar().setLocation(camera1.getLocation());
    audioMgr.getEar().setOrientation(camDir, new Vector3D(0, 1, 0));
  }
コード例 #3
0
  protected void shutdown() {
    super.shutdown();

    backgroundMusic.release(audioMgr);
    splatSound.release(audioMgr);
    resource1.unload();
    audioMgr.shutdown();

    if (gameClient != null) {
      gameClient.sendByeMessage();
      try {
        gameClient.shutdown();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    display.close();
  }