Changeset 2838 in orxonox.OLD for orxonox/branches/sound/src
- Timestamp:
- Nov 12, 2004, 2:41:26 PM (20 years ago)
- Location:
- orxonox/branches/sound/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/sound_control.cc
r2815 r2838 20 20 using namespace std; 21 21 22 // global variables 23 24 SoundControl* SoundControl::instance = 0; // singleton reference 25 int volume = SDL_MIX_MAXVOLUME; // volume 26 int done = 0; // 27 int track_number = 1; 28 Mix_Music* music = NULL; 22 29 23 30 /** … … 32 39 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 8192, bits = 0; 33 40 Uint16 audio_format = MIX_DEFAULT_FORMAT; 34 Mix_Music* music = NULL; 35 41 36 42 //initializing sound and calling Mix_OpenAudio 37 43 if(SDL_Init(SDL_INIT_AUDIO)<0){ … … 53 59 */ 54 60 SoundControl::~SoundControl () { 55 instance = NULL; 61 delete instance; 62 instance = 0; 56 63 } 57 64 … … 59 66 \brief Returns a reference to the singleton 60 67 */ 61 SoundControl* SoundControl::getObject(){ 62 static SoundControl instance; 63 return &instance; 64 } 65 68 SoundControl* SoundControl::getInstance() { 69 if (instance == 0) { 70 instance = new SoundControl; 71 } 72 return instance; 73 } 74 75 void SoundControl::deleteInstance() { 76 ~SoundControl(); 77 } 66 78 67 79 /** … … 74 86 bits=audio_format&0xFF; 75 87 printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate, bits, audio_channels > 1 ? "stereo" : "mono", audio_buffers ); 76 77 int volume = SDL_MIX_MAXVOLUME;78 88 Mix_VolumeMusic(volume); 79 int track_number = 1;80 int done = 0;81 89 } 82 90 … … 194 202 void SoundControl::trackSelect () { 195 203 switch (track_number) { 196 case 1: 204 case 1: 197 205 music = Mix_LoadMUS("luke_grey_orxonox1.ogg"); 206 if(Mix_PlayMusic(music, 1) == -1){ 207 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 208 } 209 Mix_HookMusicFinished(musicDone); 198 210 break; 199 211 case 2: 200 music = Mix_LoadMUS("luke_grey_orxonox2.ogg"); 212 music = Mix_LoadMUS("luke_grey_orxonox2.ogg"); 213 if(Mix_PlayMusic(music, 1) == -1){ 214 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 215 } 216 Mix_HookMusicFinished(musicDone); 201 217 break; 202 218 case 3: 203 219 music = Mix_LoadMUS("luke_grey_orxonox3.ogg"); 204 break; 220 if(Mix_PlayMusic(music, 1) == -1){ 221 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 222 } 223 Mix_HookMusicFinished(musicDone); 224 break; 205 225 case 4: 206 226 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg"); 227 if(Mix_PlayMusic(music, 1) == -1){ 228 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 229 } 230 Mix_HookMusicFinished(musicDone); 207 231 break; 208 232 case 5: 209 233 music = Mix_LoadMUS("nomenes_orxonox.ogg"); 234 if(Mix_PlayMusic(music, 1) == -1){ 235 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 236 } 237 Mix_HookMusicFinished(musicDone); 210 238 break; 211 239 case 6: 212 240 music = Mix_LoadMUS("nomenes_funkadudu.ogg"); 213 break; 241 if(Mix_PlayMusic(music, 1) == -1){ 242 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 243 } 244 Mix_HookMusicFinished(musicDone); 245 break; 214 246 } 215 247 } -
orxonox/branches/sound/src/sound_control.h
r2815 r2838 7 7 8 8 public: 9 SoundControl* getObject(); 9 static SoundControl* getInstance(); 10 static void deleteInstance(); 10 11 void setNumberOfChannels(int number_of channels); 11 12 int playMod(char* filename); … … 21 22 void trackSelect(); 22 23 24 protected: 25 void initialise(); 26 SoundControl(); 27 ~SoundControl(); 28 23 29 private: 24 void initialise(); 25 //SoundControl singleton object must be made via getObject() 26 SoundControl(); 27 ~SoundControl() 30 static SoundControl* instance; 31 28 32 } 29 33 -
orxonox/branches/sound/src/sound_test.cc
r2815 r2838 21 21 using namespace std; 22 22 23 SoundControl* test; 23 24 24 25 SoundTest::SoundTest () { 25 26 test = SoundControl::getInstance(); 26 27 } 27 28 … … 41 42 sound.~SoundControl(); 42 43 } 43 -
orxonox/branches/sound/src/sound_test.h
r2815 r2838 11 11 SoundTest (); 12 12 ~SoundTest (); 13 13 void main (void); 14 14 }; 15 15
Note: See TracChangeset
for help on using the changeset viewer.