Esempio n. 1
0
  /**
   * Set the mod thats being streamed if any
   *
   * @param sound The mod being streamed
   */
  void setMOD(MODSound sound) {
    if (!soundWorks) {
      return;
    }

    currentMusic = sources.get(0);
    stopSource(0);

    this.mod = sound;
    if (sound != null) {
      this.stream = null;
    }
    paused = false;
  }
Esempio n. 2
0
  public void updateALSound(ALChannel[] chans, SoundLoop[] entities) {
    for (int i = 0; i < chans.length; i++) {
      ALChannel ch = chans[i];

      // Detect end of playback so channel can be freed
      if (ch.source_playing && !isPlaying(ch.chanIndex)) {
        ch.source_playing = false;
        ch.sfx = null;
      }

      Vector3f origin = ch.origin;
      if (origin == null || !ch.fixed_origin) {
        origin = entities[ch.entNum].origin;
        velocity.set(entities[ch.entNum].velocity);
      } else {
        velocity.set(0, 0, 0);
      }

      if (ch.dirty) {
        if (ch.sfx != null) {
          // Start

          int result =
              playAsSoundAt(
                  ch.sfx.getBufferID(),
                  ch.chanIndex,
                  1.0f,
                  1.0f,
                  ch.loop,
                  origin.x,
                  origin.y,
                  origin.z,
                  velocity.x,
                  velocity.y,
                  velocity.z,
                  false);

          if (result == -1) {
            ch.source_playing = false;
            ch.sfx = null;
          } else {
            ch.source_playing = true;
          }

        } else {
          if (ch.source_playing && ch.sfx == null) {
            // Stop
            stopSource(ch.chanIndex);
            ch.source_playing = false;
          }
        }
        ch.dirty = false;
      } else {
        if (ch.source_playing) {
          // Update source position & velocity
          updateSource(
              ch.chanIndex, origin.x, origin.y, origin.z, velocity.x, velocity.y, velocity.z);
        }
      }
    }
  }