Changeset 4885 in orxonox.OLD for orxonox/trunk/src/lib/sound
- Timestamp:
- Jul 18, 2005, 3:36:18 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/sound/sound_engine.cc
r4836 r4885 91 91 * creates a SoundSource at position sourceNode with the SoundBuffer buffer 92 92 */ 93 SoundSource::SoundSource( SoundBuffer* buffer, PNode* sourceNode)93 SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer) 94 94 { 95 95 this->setClassID(CL_SOUND_SOURCE, "SoundSource"); … … 106 106 if ((result = alGetError()) != AL_NO_ERROR) 107 107 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()); 109 110 alSourcef (this->sourceID, AL_PITCH, 1.0 ); 110 111 alSourcef (this->sourceID, AL_GAIN, 1.0 ); … … 121 122 } 122 123 123 124 124 /** 125 125 * Plays back a SoundSource … … 128 128 { 129 129 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 */ 136 void SoundSource::play(const SoundBuffer* buffer) 137 { 138 alSourcei (this->sourceID, AL_BUFFER, buffer->getID()); 139 alSourcePlay(this->sourceID); 140 141 if (unlikely(this->buffer != NULL)) 142 alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID()); 130 143 } 131 144 … … 230 243 SoundSource* SoundEngine::createSource(const char* fileName, PNode* sourceNode) 231 244 { 232 return new SoundSource( (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL), sourceNode);245 return new SoundSource(sourceNode, (SoundBuffer*)ResourceManager::getInstance()->load(fileName, WAV, RP_LEVEL)); 233 246 } 234 247 -
orxonox/trunk/src/lib/sound/sound_engine.h
r4836 r4885 27 27 28 28 /** @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; } 30 30 31 31 private: … … 40 40 { 41 41 public: 42 SoundSource( SoundBuffer* buffer, PNode* sourceNode= NULL);42 SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL); 43 43 ~SoundSource(); 44 44 45 45 // user interaction 46 46 void play(); 47 void play(const SoundBuffer* buffer); 47 48 void stop(); 48 49 void pause(); … … 53 54 inline ALuint getID() const { return this->sourceID; } 54 55 /** @returns the SoundBuffer of this Source */ 55 inline SoundBuffer* getBuffer() const { return this->buffer; }56 inline const SoundBuffer* getBuffer() const { return this->buffer; } 56 57 /** @returns the SourceNode of this Source */ 57 inline PNode* getNode() const { return this->sourceNode;}58 inline const PNode* getNode() const { return this->sourceNode;} 58 59 59 60 void setRolloffFactor(ALfloat rolloffFactor); 60 61 61 62 private: 62 ALuint sourceID; //!< The ID of the Source63 SoundBuffer* buffer; //!< The buffer to play in this source.64 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. 65 66 }; 66 67
Note: See TracChangeset
for help on using the changeset viewer.