Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10695 in orxonox.OLD for trunk/src/lib/sound


Ignore:
Timestamp:
Jun 14, 2007, 4:46:18 PM (17 years ago)
Author:
snellen
Message:

changes on soundengine and mover by fabian landau

Location:
trunk/src/lib/sound
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/sound_engine.cc

    r10618 r10695  
    317317      alSourcef (source, AL_PITCH,    1.0      );
    318318      alSourcef (source, AL_GAIN,     this->getEffectsVolume() );
     319      alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
    319320      alSourcei (source, AL_LOOPING,  AL_FALSE );
    320321      this->ALSources.push(source);
  • trunk/src/lib/sound/sound_source.cc

    r9869 r10695  
    126126      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    127127      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    128       alSourcef (this->sourceID, AL_GAIN, 1);
     128//      alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
     129      alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
    129130      alSourcePlay(this->sourceID);
    130131
     
    151152    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    152153    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    153     alSourcef (this->sourceID, AL_GAIN, 1);
     154//    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
     155    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
    154156
    155157    alSourcePlay(this->sourceID);
     
    168170   * @param buffer the buffer to play back on this Source
    169171   * @param gain the gain of the sound buffer
    170   */
    171   void SoundSource::play(const SoundBuffer& buffer, float gain)
     172   * @param rolloff the rolloff of the sound buffer
     173  */
     174  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff)
    172175  {
    173176    if (!this->retrieveSource())
     
    180183    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    181184    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     185    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
    182186    alSourcef (this->sourceID, AL_GAIN, gain);
    183187
     
    193197
    194198  /**
    195    * @brief Plays back buffer on this Source with gain and looping possibility
     199   * @brief Plays back buffer on this Source with gain, rolloff and looping possibility
    196200   * @param buffer the buffer to play back on this Source
    197    *  @param gain the gain of the sound buffer
     201   * @param gain the gain of the sound buffer
     202   * @param rolloff the rolloff of the sound buffer
    198203   * @param loop if true, sound gets looped
    199204   */
    200   void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
     205  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff, bool loop)
    201206  {
    202207    if (!this->retrieveSource())
     
    215220
    216221    alSourcef (this->sourceID, AL_GAIN, gain);
     222    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
    217223
    218224    alSourcePlay(this->sourceID);
     
    226232  }
    227233
     234  /**
     235   * @brief Plays back buffer on this Source with looping possibility
     236   * @param buffer the buffer to play back on this Source
     237   * @param loop if true, sound gets looped
     238   */
     239  void SoundSource::play(const SoundBuffer& buffer, bool loop)
     240  {
     241    if (!this->retrieveSource())
     242    {
     243      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     244      return;
     245    }
     246
     247    alSourceStop(this->sourceID);
     248    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
     249
     250    if (loop)
     251      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     252    else
     253      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     254
     255    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
     256
     257    alSourcePlay(this->sourceID);
     258
     259    if (unlikely(this->buffer.getID() != 0))
     260      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
     261    this->bPlay = true;
     262
     263    if (DEBUG_LEVEL >= 3)
     264      SoundEngine::checkError("Play Source", __LINE__);
     265  }
     266 
    228267  /**
    229268   * @brief Changes the volume of an (active) buffer
  • trunk/src/lib/sound/sound_source.h

    r9869 r10695  
    3030    void play();
    3131    void play(const SoundBuffer& buffer);
    32     void play(const SoundBuffer& buffer, float gain);
    33     void play(const SoundBuffer& buffer, float gain, bool loop);
     32    void play(const SoundBuffer& buffer, float gain, float rolloff);
     33    void play(const SoundBuffer& buffer, float gain, float rolloff, bool loop);
     34    void play(const SoundBuffer& buffer, bool loop);
    3435
    3536    void gain(const SoundBuffer& buffer, float gain);
Note: See TracChangeset for help on using the changeset viewer.