Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4883 in orxonox.OLD for orxonox/branches/weaponSystem/src/lib/sound


Ignore:
Timestamp:
Jul 17, 2005, 4:02:36 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/weaponSystem: connecting sounds to the weapon works fine now

Location:
orxonox/branches/weaponSystem/src/lib/sound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/weaponSystem/src/lib/sound/sound_engine.cc

    r4880 r4883  
    9191 *  creates a SoundSource at position sourceNode with the SoundBuffer buffer
    9292*/
    93 SoundSource::SoundSource(SoundBuffer* buffer, PNode* sourceNode)
     93SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
    9494{
    9595  this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     
    106106  if ((result = alGetError()) != AL_NO_ERROR)
    107107    SoundEngine::PrintALErrorString(result);
    108   alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
     108  if (this->buffer != NULL)
     109    alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
    109110  alSourcef (this->sourceID, AL_PITCH,    1.0      );
    110111  alSourcef (this->sourceID, AL_GAIN,     1.0      );
     
    127128{
    128129  alSourcePlay(this->sourceID);
     130}
     131
     132/**
     133 * Plays back buffer on this Source
     134 * @param buffer the buffer to play back on this Source
     135 */
     136void SoundSource::play(const SoundBuffer* buffer)
     137{
     138  alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     139  alSourcePlay(this->sourceID);
     140//  printf("playing sound\n");
    129141}
    130142
     
    229241SoundSource* SoundEngine::createSource(const char* fileName, PNode* sourceNode)
    230242{
    231   return new SoundSource((SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL), sourceNode);
     243  return new SoundSource(sourceNode, (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL));
    232244}
    233245
  • orxonox/branches/weaponSystem/src/lib/sound/sound_engine.h

    r4878 r4883  
    2727
    2828  /** @returns the ID of the buffer used in this SoundBuffer */
    29   inline ALuint getID() { return this->bufferID; }
     29  inline ALuint getID() const { return this->bufferID; }
    3030
    3131 private:
     
    3737
    3838//! A class that represents a SoundSource
    39 /**
    40  * @todo ability to play back different SoundBuffers on the same SounSource
    41  */
    4239class SoundSource : public BaseObject
    4340{
    4441 public:
    45   SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL);
     42  SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL);
    4643  ~SoundSource();
    4744
    4845  // user interaction
    4946  void play();
     47  void play(const SoundBuffer* buffer);
    5048  void stop();
    5149  void pause();
     
    5654  inline ALuint getID() const { return this->sourceID; }
    5755  /** @returns the SoundBuffer of this Source */
    58   inline SoundBuffer* getBuffer() const { return this->buffer; }
     56  inline const SoundBuffer* getBuffer() const { return this->buffer; }
    5957  /** @returns the SourceNode of this Source */
    60   inline PNode* getNode() const { return this->sourceNode;}
     58  inline const PNode* getNode() const { return this->sourceNode;}
    6159
    6260  void setRolloffFactor(ALfloat rolloffFactor);
    6361
    6462 private:
    65   ALuint           sourceID;              //!< The ID of the Source
    66   SoundBuffer*     buffer;                //!< The buffer to play in this source.
    67   PNode*           sourceNode;            //!< The SourceNode represente the position/velocity... of this source.
     63  ALuint                 sourceID;              //!< The ID of the Source
     64  const SoundBuffer*     buffer;                //!< The buffer to play in this source.
     65  const PNode*           sourceNode;            //!< The SourceNode represente the position/velocity... of this source.
    6866};
    6967
Note: See TracChangeset for help on using the changeset viewer.