Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2006, 3:21:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: SoundSource completely added as a Resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/sound/sound_source.cc

    r9715 r9805  
    1919#include "sound_engine.h"
    2020
    21 #include "alincl.h"
    2221#include "compiler.h"
    2322#include "debug.h"
     
    2928  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
    3029  */
    31   SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
     30  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer)
    3231  {
    3332    this->registerObject(this, SoundSource::_objectList);
     
    120119  void SoundSource::play()
    121120  {
    122     if (this->buffer && this->retrieveSource())
     121    if (this->retrieveSource())
    123122    {
    124123      if (this->bPlay)
    125124        alSourceStop(this->sourceID);
    126125
    127       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     126      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    128127      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    129128      alSourcef (this->sourceID, AL_GAIN, 1);
     
    141140  * @param buffer the buffer to play back on this Source
    142141  */
    143   void SoundSource::play(const SoundBuffer* buffer)
     142  void SoundSource::play(const SoundBuffer& buffer)
    144143  {
    145144    if (!this->retrieveSource())
     
    150149
    151150    alSourceStop(this->sourceID);
    152     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     151    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    153152    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    154153    alSourcef (this->sourceID, AL_GAIN, 1);
     
    156155    alSourcePlay(this->sourceID);
    157156
    158     if (unlikely(this->buffer != NULL))
    159       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     157    if (unlikely(this->buffer.getID() != 0))
     158      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    160159    this->bPlay = true;
    161160
     
    170169   * @param gain the gain of the sound buffer
    171170  */
    172   void SoundSource::play(const SoundBuffer* buffer, float gain)
     171  void SoundSource::play(const SoundBuffer& buffer, float gain)
    173172  {
    174173    if (!this->retrieveSource())
     
    179178
    180179    alSourceStop(this->sourceID);
    181     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     180    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    182181    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    183182    alSourcef (this->sourceID, AL_GAIN, gain);
     
    185184    alSourcePlay(this->sourceID);
    186185
    187     if (unlikely(this->buffer != NULL))
    188       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     186    if (unlikely(this->buffer.getID() != 0))
     187      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    189188    this->bPlay = true;
    190189
     
    199198   * @param loop if true, sound gets looped
    200199   */
    201   void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
     200  void SoundSource::play(const SoundBuffer& buffer, float gain, bool loop)
    202201  {
    203202    if (!this->retrieveSource())
     
    208207
    209208    alSourceStop(this->sourceID);
    210     alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     209    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
    211210
    212211    if (loop)
     
    219218    alSourcePlay(this->sourceID);
    220219
    221     if (unlikely(this->buffer != NULL))
    222       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     220    if (unlikely(this->buffer.getID() != 0))
     221      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
    223222    this->bPlay = true;
    224223
     
    232231   * @param gain the new gain value
    233232   */
    234   void SoundSource::gain(const SoundBuffer* buffer, float gain)
     233  void SoundSource::gain(const SoundBuffer& buffer, float gain)
    235234  {
    236235    // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     
    347346  * @param duration time perios to fade in
    348347  */
    349   void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
     348  void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration)
    350349  {
    351350    //if (this->buffer && this->retrieveSource())
Note: See TracChangeset for help on using the changeset viewer.