Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 26, 2006, 3:36:16 PM (18 years ago)
Author:
patrick
Message:

trunk: merged the weather engine branche to the trunk

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

Legend:

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

    r8495 r8793  
    164164
    165165  /**
    166   * @brief Plays back buffer on this Source with gain
    167   * @param buffer the buffer to play back on this Source
     166   * @brief Plays back buffer on this Source with gain
     167   * @param buffer the buffer to play back on this Source
     168   * @param gain the gain of the sound buffer
    168169  */
    169170  void SoundSource::play(const SoundBuffer* buffer, float gain)
     
    189190      SoundEngine::checkError("Play Source", __LINE__);
    190191  }
    191  
    192    /**
     192
     193  /**
    193194   * @brief Plays back buffer on this Source with gain and looping possibility
    194195   * @param buffer the buffer to play back on this Source
    195     */
     196   *  @param gain the gain of the sound buffer
     197   * @param loop if true, sound gets looped
     198   */
    196199  void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
    197200  {
     
    204207    alSourceStop(this->sourceID);
    205208    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
    206    
     209
    207210    if (loop)
    208         alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     211      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    209212    else
    210         alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    211    
     213      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     214
    212215    alSourcef (this->sourceID, AL_GAIN, gain);
    213216
     
    220223    if (DEBUG_LEVEL >= 3)
    221224      SoundEngine::checkError("Play Source", __LINE__);
    222   }
    223 
    224 
    225   /**
    226   * @brief Stops playback of a SoundSource
    227   */
     225  }
     226
     227  /**
     228   * @brief Changes the volume of an (active) buffer
     229   * @param buffer the buffer to play back on this Source
     230   * @param gain the new gain value
     231   */
     232  void SoundSource::gain(const SoundBuffer* buffer, float gain)
     233  {
     234    // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     235    alSourcef (this->sourceID, AL_GAIN, gain);
     236  }
     237
     238  /**
     239   * @brief Stops playback of a SoundSource
     240   */
    228241  void SoundSource::stop()
    229242  {
  • trunk/src/lib/sound/sound_source.h

    r8495 r8793  
    1414namespace OrxSound
    1515{
    16         class SoundBuffer;
    17         //! A class that represents a SoundSource
    18         class SoundSource : public BaseObject
    19         {
    20                 public:
    21                         SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
    22                         SoundSource(const SoundSource& source);
    23                         SoundSource& operator=(const SoundSource& source);
    24                         bool operator==(const SoundSource& source);
    25                        
    26                         virtual ~SoundSource();
    27                        
    28                         // user interaction
    29                         void play();
    30                         void play(const SoundBuffer* buffer);
    31                         void play(const SoundBuffer* buffer, float gain);
    32       void play(const SoundBuffer* buffer, float gain, bool loop);   
     16  class SoundBuffer;
     17  //! A class that represents a SoundSource
     18  class SoundSource : public BaseObject
     19  {
     20  public:
     21    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
     22    SoundSource(const SoundSource& source);
     23    SoundSource& operator=(const SoundSource& source);
     24    bool operator==(const SoundSource& source);
    3325
    34                         void stop();
    35                         void pause();
    36                         void rewind();
    37                         void fadein(const SoundBuffer* buffer, ALfloat duration);
    38                        
    39                        
    40                         // development functions
    41                         /** @returns The ID of this Source */
    42                         inline ALuint getID() const { return this->sourceID; };
    43                         /** @returns true, if the Source is Playing */
    44                         inline bool   isPlaying() const { return this->bPlay; };
    45                         void setSourceNode(const PNode* sourceNode);
    46                         /** @returns the SoundBuffer of this Source */
    47                         inline const SoundBuffer* getBuffer() const { return this->buffer; };
    48                         /** @returns the SourceNode of this Source */
    49                         inline const PNode* getNode() const { return this->sourceNode; };
    50                         /** @param resident if the Source is Resident */
    51                         inline void setResident(bool resident) { this->resident = resident; };
    52                         /** @returns true if the alSource is Resident */
    53                         inline bool isResident() const { return this->resident; };
    54                        
    55                         void setRolloffFactor(ALfloat rolloffFactor);
    56                        
    57                         static void resetSource(ALuint sourceID);
    58                
    59                 private:
    60                         bool retrieveSource();
    61                        
    62                 private:
    63                         bool                   bPlay;           //!< If the Source is Playing.
    64                         bool                   resident;        //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
    65                         ALuint                 sourceID;        //!< The ID of the Source
    66                         const SoundBuffer*     buffer;          //!< The buffer to play in this source.
    67                         const PNode*           sourceNode;      //!< The SourceNode representing the position/velocity... of this source.
    68         };
     26    virtual ~SoundSource();
     27
     28    // user interaction
     29    void play();
     30    void play(const SoundBuffer* buffer);
     31    void play(const SoundBuffer* buffer, float gain);
     32    void play(const SoundBuffer* buffer, float gain, bool loop);
     33
     34    void gain(const SoundBuffer* buffer, float gain);
     35
     36    void stop();
     37    void pause();
     38    void rewind();
     39    void fadein(const SoundBuffer* buffer, ALfloat duration);
     40
     41    // development functions
     42    /** @returns The ID of this Source */
     43    inline ALuint getID() const { return this->sourceID; };
     44    /** @returns true, if the Source is Playing */
     45    inline bool isPlaying() const { return this->bPlay; };
     46    void setSourceNode(const PNode* sourceNode);
     47    /** @returns the SoundBuffer of this Source */
     48    inline const SoundBuffer* getBuffer() const { return this->buffer; };
     49    /** @returns the SourceNode of this Source */
     50    inline const PNode* getNode() const { return this->sourceNode; };
     51    /** @param resident if the Source is Resident */
     52    inline void setResident(bool resident) { this->resident = resident; };
     53    /** @returns true if the alSource is Resident */
     54    inline bool isResident() const { return this->resident; };
     55
     56    void setRolloffFactor(ALfloat rolloffFactor);
     57
     58    static void resetSource(ALuint sourceID);
     59
     60  private:
     61    bool                   retrieveSource();
     62
     63  private:
     64    bool                   bPlay;       //!< If the Source is Playing.
     65    bool                   resident;    //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
     66    ALuint                 sourceID;    //!< The ID of the Source
     67    const SoundBuffer*     buffer;      //!< The buffer to play in this source.
     68    const PNode*           sourceNode;  //!< The SourceNode representing the position/velocity... of this source.
     69  };
    6970}
    7071#endif /* _SOUND_SOURCE_H */
Note: See TracChangeset for help on using the changeset viewer.