Changeset 8495 in orxonox.OLD for trunk/src/lib/sound
- Timestamp:
- Jun 15, 2006, 9:50:56 PM (18 years ago)
- Location:
- trunk/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/sound/sound_source.cc
r8362 r8495 1 1 /* 2 3 4 5 6 7 8 9 10 11 12 13 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: ... 14 14 */ 15 15 … … 85 85 else 86 86 this->stop(); 87 return *this;88 87 } 89 88 … … 190 189 SoundEngine::checkError("Play Source", __LINE__); 191 190 } 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)) 204 217 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 } 261 223 262 224 … … 381 343 } 382 344 383 // 384 385 // 386 // 387 // 345 // alSourcePlay(this->sourceID); 346 347 // if (DEBUG_LEVEL >= 3) 348 // SoundEngine::checkError("Loop Source", __LINE__); 349 // this->bPlay = true; 388 350 //} 389 351 -
trunk/src/lib/sound/sound_source.h
r8255 r8495 30 30 void play(const SoundBuffer* buffer); 31 31 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 35 34 void stop(); 36 35 void pause();
Note: See TracChangeset
for help on using the changeset viewer.