Changeset 2854 in orxonox.OLD for orxonox/branches/sound/src/sound_control.cc
- Timestamp:
- Nov 14, 2004, 4:44:31 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/src/sound_control.cc
r2838 r2854 15 15 16 16 #include "sound_control.h" 17 #include <string.h>18 #include "SDL_mixer.h"19 17 20 18 using namespace std; 21 19 22 20 // global variables 23 24 SoundControl* SoundControl::instance = 0; // singleton reference 25 int volume = SDL_MIX_MAXVOLUME; // volume 26 int done = 0; // 21 SoundControl* SoundControl::instance = NULL; // singleton reference 22 int volume = SDL_MIX_MAXVOLUME; 23 int done = 0; 27 24 int track_number = 1; 28 Mix_Music* music = NULL; 25 static Mix_Music* music = NULL; 26 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 16384, bits = 0; 27 Uint16 audio_format = MIX_DEFAULT_FORMAT; 28 29 29 30 30 /** … … 35 35 */ 36 36 SoundControl::SoundControl () { 37 38 //setup parameters 39 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 8192, bits = 0; 40 Uint16 audio_format = MIX_DEFAULT_FORMAT; 41 42 //initializing sound and calling Mix_OpenAudio 37 38 /* 39 initializing sound and calling Mix_OpenAudio 43 40 if(SDL_Init(SDL_INIT_AUDIO)<0){ 44 printf("SDL_Init: \n"); 45 exit(1); 41 printf("SDL_Init: INIT_AUDIO error.\n"); 46 42 } 43 */ 47 44 48 45 if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 49 printf("Mix_OpenAudio: \n"); 50 exit(1); 46 printf("Mix_OpenAudio: Failed to open audio!\n"); 51 47 } 52 48 … … 56 52 57 53 /** 58 \brief De structor for the singleton instance54 \brief Default destructor 59 55 */ 60 56 SoundControl::~SoundControl () { 61 delete instance;62 instance = 0;63 57 } 64 58 … … 67 61 */ 68 62 SoundControl* SoundControl::getInstance() { 69 if (instance == 0) {63 if (instance == NULL) { 70 64 instance = new SoundControl; 71 65 } … … 74 68 75 69 void SoundControl::deleteInstance() { 76 ~SoundControl(); 70 delete instance; 71 instance = NULL; 77 72 } 78 73 … … 186 181 */ 187 182 void SoundControl::pauseMusic () { 188 Mix_PauseMusic() 183 Mix_PauseMusic(); 189 184 } 190 185 … … 194 189 */ 195 190 void SoundControl::resumeMusic () { 196 Mix_ResumeMusic() 191 Mix_ResumeMusic(); 197 192 } 198 193 … … 200 195 \brief Selects the track of all orxonox tracks 201 196 */ 202 void SoundControl::trackSelect 197 void SoundControl::trackSelect() { 203 198 switch (track_number) { 204 199 case 1: … … 219 214 music = Mix_LoadMUS("luke_grey_orxonox3.ogg"); 220 215 if(Mix_PlayMusic(music, 1) == -1){ 221 printf("Mix_PlayMusic: %s\n",Mix_GetError());222 }223 Mix_HookMusicFinished(musicDone);224 break;216 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 217 } 218 Mix_HookMusicFinished(musicDone); 219 break; 225 220 case 4: 226 221 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg"); … … 239 234 case 6: 240 235 music = Mix_LoadMUS("nomenes_funkadudu.ogg"); 241 if(Mix_PlayMusic(music, 1) == -1){242 printf("Mix_PlayMusic: %s\n",Mix_GetError());243 }244 Mix_HookMusicFinished(musicDone);245 break;236 if(Mix_PlayMusic(music, 1) == -1){ 237 printf("Mix_PlayMusic: %s\n",Mix_GetError()); 238 } 239 Mix_HookMusicFinished(musicDone); 240 break; 246 241 } 247 242 } … … 251 246 \brief Hooked by playOgg at end of .ogg playback 252 247 */ 253 void SoundControl::musicDone () { 254 track_number++; 248 void SoundControl::musicDone() { 255 249 Mix_HaltMusic(); 256 250 Mix_FreeMusic(music);
Note: See TracChangeset
for help on using the changeset viewer.