Changeset 1541 for code/branches/script_trigger/src/audio
- Timestamp:
- Jun 5, 2008, 10:59:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/script_trigger/src/audio/AudioManager.cc
r1089 r1541 39 39 namespace audio 40 40 { 41 42 41 AudioManager::AudioManager() 42 { 43 43 ambientPath = "audio/ambient"; 44 44 45 45 alutInit(NULL, 0); 46 } 46 47 48 AudioManager::~AudioManager() 49 { 50 for (unsigned int i=0;i<bgSounds.size();i++) 51 { 52 bgSounds[i]->release(); 53 } 54 alutExit(); 55 } 47 56 48 } 57 void AudioManager::ambientStart() 58 { 59 // currentBgSound = 0; 60 if (bgSounds.size() > 0) 61 { 62 currentBgSound = rand() % bgSounds.size(); 63 if(!bgSounds[currentBgSound]->playback()) 64 { 65 orxonox::Error("Ogg refused to play."); 66 } 67 else 68 { 69 COUT(3) << "Info: Started playing background sound" << std::endl; 70 } 71 } 72 } 49 73 50 AudioManager::~AudioManager() 51 { 52 for (unsigned int i=0;i<bgSounds.size();i++) 53 { 54 bgSounds[i]->release(); 55 } 56 alutExit(); 57 } 74 void AudioManager::ambientStop() 75 { 76 COUT(3) << "Info: Stopped playing background sound" << std::endl; 77 } 58 78 59 void AudioManager::ambientStart() 60 { 61 // currentBgSound = 0; 62 if (bgSounds.size() > 0) 63 { 64 currentBgSound = rand() % bgSounds.size(); 65 if(!bgSounds[currentBgSound]->playback()) 66 { 67 orxonox::Error("Ogg refused to play."); 68 } 69 else 70 { 71 COUT(3) << "Info: Started playing background sound" << std::endl; 72 } 73 } 74 } 79 void AudioManager::ambientAdd(std::string file) 80 { 81 std::string path = ambientPath + "/" + file + ".ogg"; 82 AudioStream* tmp = new AudioStream(path); 83 tmp->open(); 84 if (tmp->isLoaded()) 85 { 86 bgSounds.push_back(tmp); 87 COUT(3) << "Info: Added background sound " << file << std::endl; 88 } 89 } 75 90 76 void AudioManager::ambientStop() 77 { 78 COUT(3) << "Info: Stopped playing background sound" << std::endl; 79 } 80 81 void AudioManager::ambientAdd(std::string file) 82 { 83 std::string path = ambientPath + "/" + file + ".ogg"; 84 AudioStream* tmp = new AudioStream(path); 85 tmp->open(); 86 if (tmp->isLoaded()) 87 { 88 bgSounds.push_back(tmp); 89 COUT(3) << "Info: Added background sound " << file << std::endl; 90 } 91 } 92 93 void AudioManager::tick(float dt) 94 { 95 if (bgSounds.size() > 0) 96 { 97 if (bgSounds[currentBgSound]->isLoaded()) 98 { 99 bool playing = bgSounds[currentBgSound]->update(); 100 if(!bgSounds[currentBgSound]->playing() && playing) 101 { 102 if(!bgSounds[currentBgSound]->playback()) 103 orxonox::Error("Ogg abruptly stopped."); 104 else 105 orxonox::Error("Ogg stream was interrupted."); 106 107 } 108 if (!playing) 109 { 110 // if (currentBgSound < bgSounds.size()-1) 111 // { 112 // currentBgSound++; 113 // } 114 // else 115 // { 116 // currentBgSound=0; 117 // } 91 void AudioManager::tick(float dt) 92 { 93 if (bgSounds.size() > 0) 94 { 95 if (bgSounds[currentBgSound]->isLoaded()) 96 { 97 bool playing = bgSounds[currentBgSound]->update(); 98 if(!bgSounds[currentBgSound]->playing() && playing) 99 { 100 if(!bgSounds[currentBgSound]->playback()) 101 orxonox::Error("Ogg abruptly stopped."); 102 else 103 orxonox::Error("Ogg stream was interrupted."); 104 } 105 if (!playing) 106 { 107 // if (currentBgSound < bgSounds.size()-1) 108 // { 109 // currentBgSound++; 110 // } 111 // else 112 // { 113 // currentBgSound=0; 114 // } 118 115 // switch to next sound in list/array 119 116 currentBgSound = ++currentBgSound % bgSounds.size(); 120 117 121 122 123 124 125 126 127 128 129 130 131 118 if (!bgSounds[currentBgSound]->isLoaded()) 119 { 120 bgSounds[currentBgSound]->release(); 121 bgSounds[currentBgSound]->open(); 122 } 123 bgSounds[currentBgSound]->playback(); 124 COUT(3) << "Info: Playing next background sound" << std::endl; 125 } 126 } 127 } 128 } 132 129 133 void AudioManager::setPos(std::vector<float> newPosition) 134 { 130 void AudioManager::setPos(std::vector<float> newPosition) 131 { 132 } 135 133 136 } 134 void AudioManager::setSpeed(std::vector<float> newSpeed) 135 { 136 } 137 137 138 void AudioManager::setSpeed(std::vector<float> newSpeed) 139 { 138 void AudioManager::setOri(std::vector<float> at, std::vector<float> up) 139 { 140 } 140 141 141 }142 143 void AudioManager::setOri(std::vector<float> at, std::vector<float> up)144 {145 146 }147 142 }
Note: See TracChangeset
for help on using the changeset viewer.