Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 15, 2006, 9:50:56 PM (19 years ago)
Author:
bensch
Message:

merged the branche atmos back. no conflicts

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

Legend:

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

    r8362 r8495  
    11/*
    2         orxonox - the future of 3D-vertical-scrollers
    3 
    4         Copyright (C) 2004 orx
    5 
    6         This program is free software; you can redistribute it and/or modify
    7         it under the terms of the GNU General Public License as published by
    8         the Free Software Foundation; either version 2, or (at your option)
    9         any later version.
    10 
    11         ### File Specific:
    12         main-programmer: Benjamin Grauer
    13         co-programmer: ...
     2  orxonox - the future of 3D-vertical-scrollers
     3 
     4  Copyright (C) 2004 orx
     5 
     6  This program is free software; you can redistribute it and/or modify
     7  it under the terms of the GNU General Public License as published by
     8  the Free Software Foundation; either version 2, or (at your option)
     9  any later version.
     10 
     11  ### File Specific:
     12  main-programmer: Benjamin Grauer
     13  co-programmer: ...
    1414*/
    1515
     
    8585    else
    8686      this->stop();
    87     return *this;
    8887  }
    8988
     
    190189      SoundEngine::checkError("Play Source", __LINE__);
    191190  }
    192 
    193 
    194   /**
    195   * @brief Plays and loops back a SoundSource
    196   */
    197   void SoundSource::loop()
    198   {
    199     if (this->buffer && this->retrieveSource())
    200     {
    201       if (this->bPlay)
    202         alSourceStop(this->sourceID);
    203 
     191 
     192   /**
     193   * @brief Plays back buffer on this Source with gain and looping possibility
     194   * @param buffer the buffer to play back on this Source
     195    */
     196  void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
     197  {
     198    if (!this->retrieveSource())
     199    {
     200      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     201      return;
     202    }
     203
     204    alSourceStop(this->sourceID);
     205    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     206   
     207    if (loop)
     208        alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     209    else
     210        alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     211   
     212    alSourcef (this->sourceID, AL_GAIN, gain);
     213
     214    alSourcePlay(this->sourceID);
     215
     216    if (unlikely(this->buffer != NULL))
    204217      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    205       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    206       alSourcef (this->sourceID, AL_GAIN, 1);
    207       alSourcePlay(this->sourceID);
    208 
    209       if (DEBUG_LEVEL >= 3)
    210         SoundEngine::checkError("Play Source", __LINE__);
    211       this->bPlay = true;
    212     }
    213   }
    214 
    215   /**
    216   * @brief Plays and loops buffer on this Source
    217   * @param buffer the buffer to play back on this Source
    218   */
    219   void SoundSource::loop(const SoundBuffer* buffer)
    220   {
    221     if (this->buffer && this->retrieveSource())
    222     {
    223       if (this->bPlay)
    224         alSourceStop(this->sourceID);
    225 
    226       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    227       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    228       alSourcef (this->sourceID, AL_GAIN, 1);
    229 
    230       alSourcePlay(this->sourceID);
    231 
    232       if (DEBUG_LEVEL >= 3)
    233         SoundEngine::checkError("Loop Source", __LINE__);
    234       this->bPlay = true;
    235     }
    236   }
    237 
    238 
    239   /**
    240   * @brief Plays and loops buffer on this Source with gain control
    241   * @param buffer the buffer to play back on this Source
    242   */
    243   void SoundSource::loop(const SoundBuffer* buffer, float gain)
    244   {
    245     if (this->buffer && this->retrieveSource())
    246     {
    247       if (this->bPlay)
    248         alSourceStop(this->sourceID);
    249 
    250       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    251       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    252       alSourcef (this->sourceID, AL_GAIN, gain);
    253 
    254       alSourcePlay(this->sourceID);
    255 
    256       if (DEBUG_LEVEL >= 3)
    257         SoundEngine::checkError("Loop Source", __LINE__);
    258       this->bPlay = true;
    259     }
    260   }
     218    this->bPlay = true;
     219
     220    if (DEBUG_LEVEL >= 3)
     221      SoundEngine::checkError("Play Source", __LINE__);
     222  }
    261223
    262224
     
    381343    }
    382344
    383     //  alSourcePlay(this->sourceID);
    384 
    385     //  if (DEBUG_LEVEL >= 3)
    386     //          SoundEngine::checkError("Loop Source", __LINE__);
    387     //  this->bPlay = true;
     345    //  alSourcePlay(this->sourceID);
     346
     347    //  if (DEBUG_LEVEL >= 3)
     348    //    SoundEngine::checkError("Loop Source", __LINE__);
     349    //  this->bPlay = true;
    388350    //}
    389351
  • trunk/src/lib/sound/sound_source.h

    r8255 r8495  
    3030                        void play(const SoundBuffer* buffer);
    3131                        void play(const SoundBuffer* buffer, float gain);
    32                         void loop();
    33                         void loop(const SoundBuffer* buffer);
    34                         void loop(const SoundBuffer* buffer, float gain);
     32      void play(const SoundBuffer* buffer, float gain, bool loop);   
     33
    3534                        void stop();
    3635                        void pause();
Note: See TracChangeset for help on using the changeset viewer.