Changeset 430 for code/branches/FICN/src/audio/AudioManager.cc
- Timestamp:
- Dec 5, 2007, 11:47:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/audio/AudioManager.cc
r423 r430 1 1 #include "AudioManager.h" 2 3 2 4 3 5 namespace audio … … 5 7 AudioManager::AudioManager() 6 8 { 9 ambientPath = "audio/ambient"; 10 7 11 alutInit(NULL, 0); 8 9 bgSound.open("ambient1");12 13 10 14 11 15 12 16 13 bgSound.display();14 15 if(!bgSound.playback())16 {17 orxonox::Error("Ogg refused to play.");18 }19 17 } 20 18 21 19 AudioManager::~AudioManager() 22 20 { 23 bgSound.release(); 21 for (unsigned int i=0;i<=bgSounds.size();i++) 22 { 23 bgSounds[i].release(); 24 } 24 25 alutExit(); 26 } 27 28 void AudioManager::ambientStart() 29 { 30 currentBgSound = 0; 31 if (bgSounds.size() > 0) 32 { 33 if(!bgSounds[currentBgSound].playback()) 34 { 35 orxonox::Error("Ogg refused to play."); 36 } 37 else 38 { 39 std::cout << "Started playing background sound"<<std::endl; 40 } 41 } 42 43 } 44 45 void AudioManager::ambientStop() 46 { 47 std::cout << "Stopped playing background sound"<<std::endl; 48 } 49 50 void AudioManager::ambientAdd(std::string file) 51 { 52 std::string path = ambientPath + "/" + file + ".ogg"; 53 AudioStream tmp(path); 54 tmp.open(); 55 if (tmp.isLoaded()) 56 { 57 bgSounds.push_back(tmp); 58 std::cout << "Added background sound "<<file<<std::endl; 59 } 25 60 } 26 61 27 62 void AudioManager::update() 28 63 { 29 30 if (bgSound.isLoaded()) 64 if (bgSounds.size() > 0) 31 65 { 32 bgSound.update(); 33 if(!bgSound.playing()) 34 { 35 if(!bgSound.playback()) 36 orxonox::Error("Ogg abruptly stopped."); 37 else 38 orxonox::Error("Ogg stream was interrupted."); 39 } 66 if (bgSounds[currentBgSound].isLoaded()) 67 { 68 bool playing = bgSounds[currentBgSound].update(); 69 if(!bgSounds[currentBgSound].playing() && playing) 70 { 71 if(!bgSounds[currentBgSound].playback()) 72 orxonox::Error("Ogg abruptly stopped."); 73 else 74 orxonox::Error("Ogg stream was interrupted."); 75 76 } 77 if (!playing) 78 { 79 if (currentBgSound < bgSounds.size()-1) 80 { 81 currentBgSound++; 82 } 83 else 84 { 85 currentBgSound=0; 86 } 87 if (!bgSounds[currentBgSound].isLoaded()) 88 { 89 bgSounds[currentBgSound].release(); 90 bgSounds[currentBgSound].open(); 91 } 92 bgSounds[currentBgSound].playback(); 93 std::cout << "Playing next background sound "<<std::endl; 94 } 95 } 40 96 } 41 97 }
Note: See TracChangeset
for help on using the changeset viewer.