public void startBackgroundMusic() {
   String backgroundTrack =
       "/sound/Background " + (TurnSynchronizer.synchedRandom.nextInt(4) + 1) + ".ogg";
   if (!isMuted() && hasOggPlaybackSupport() && !isPlaying(BACKGROUND_TRACK)) {
     soundSystem.backgroundMusic(
         BACKGROUND_TRACK, SoundPlayer.class.getResource(backgroundTrack), backgroundTrack, true);
   }
 }
  private boolean playSound(String sourceName, float x, float y, boolean blocking, int index) {
    if (index < MAX_SOURCES_PER_SOUND && !isMuted() && hasWavPlaybackSupport()) {
      String indexedSourceName = sourceName + index;
      if (!loaded.contains(indexedSourceName)) {
        soundSystem.newSource(
            false,
            indexedSourceName,
            SoundPlayer.class.getResource(sourceName),
            sourceName,
            false,
            x,
            y,
            0,
            SoundSystemConfig.ATTENUATION_ROLLOFF,
            SoundSystemConfig.getDefaultRolloff());
        loaded.add(indexedSourceName);
      } else if (isPlaying(indexedSourceName)) {
        if (blocking) {
          return false;
        }

        // Source already playing, create new source for same sound
        // effect.
        return playSound(sourceName, x, y, false, index + 1);
      }
      soundSystem.stop(indexedSourceName);
      soundSystem.setPriority(indexedSourceName, false);
      soundSystem.setPosition(indexedSourceName, x, y, 0);
      soundSystem.setAttenuation(indexedSourceName, SoundSystemConfig.ATTENUATION_ROLLOFF);
      soundSystem.setDistOrRoll(indexedSourceName, SoundSystemConfig.getDefaultRolloff());
      soundSystem.setPitch(indexedSourceName, 1.0f);
      soundSystem.play(indexedSourceName);
      return true;
    }
    return false;
  }
 public void setListenerPosition(float x, float y) {
   soundSystem.setListenerPosition(x, y, 50);
 }
 public void stopBackgroundMusic() {
   if (hasOggPlaybackSupport()) {
     soundSystem.stop(BACKGROUND_TRACK);
   }
 }
 private boolean isPlaying(String sourceName) {
   if (hasOggPlaybackSupport()) {
     return soundSystem.playing(sourceName);
   }
   return false;
 }
 public void shutdown() {
   if (soundSystem != null) {
     soundSystem.cleanup();
   }
 }