Changeset 2979 in orxonox.OLD for orxonox/branches/sound
- Timestamp:
- Nov 24, 2004, 5:39:05 PM (20 years ago)
- Location:
- orxonox/branches/sound/sound
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/sound/sound_control.cc
r2974 r2979 18 18 using namespace std; 19 19 20 // global variables 21 SoundControl* SoundControl::instance = NULL; // singleton reference 20 SoundControl* SoundControl::instance = NULL; 22 21 int volume = SDL_MIX_MAXVOLUME; 23 int done = 0;24 22 int track_number = 1; 25 23 static Mix_Music* music = NULL; … … 192 190 } 193 191 194 /**195 \brief Selects the track of all orxonox tracks196 */197 void SoundControl::trackSelect() {198 switch (track_number) {199 case 1:200 music = Mix_LoadMUS("luke_grey_orxonox1.ogg");201 if(Mix_PlayMusic(music, 1) == -1){202 printf("Mix_PlayMusic: %s\n",Mix_GetError());203 }204 Mix_HookMusicFinished(musicDone);205 break;206 case 2:207 music = Mix_LoadMUS("luke_grey_orxonox2.ogg");208 if(Mix_PlayMusic(music, 1) == -1){209 printf("Mix_PlayMusic: %s\n",Mix_GetError());210 }211 Mix_HookMusicFinished(musicDone);212 break;213 case 3:214 music = Mix_LoadMUS("luke_grey_orxonox3.ogg");215 if(Mix_PlayMusic(music, 1) == -1){216 printf("Mix_PlayMusic: %s\n",Mix_GetError());217 }218 Mix_HookMusicFinished(musicDone);219 break;220 case 4:221 music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg");222 if(Mix_PlayMusic(music, 1) == -1){223 printf("Mix_PlayMusic: %s\n",Mix_GetError());224 }225 Mix_HookMusicFinished(musicDone);226 break;227 case 5:228 music = Mix_LoadMUS("nomenes_orxonox.ogg");229 if(Mix_PlayMusic(music, 1) == -1){230 printf("Mix_PlayMusic: %s\n",Mix_GetError());231 }232 Mix_HookMusicFinished(musicDone);233 break;234 case 6:235 music = Mix_LoadMUS("nomenes_funkadudu.ogg");236 if(Mix_PlayMusic(music, 1) == -1){237 printf("Mix_PlayMusic: %s\n",Mix_GetError());238 }239 Mix_HookMusicFinished(musicDone);240 break;241 }242 }243 244 192 245 193 /** -
orxonox/branches/sound/sound/sound_control.h
r2974 r2979 22 22 void pauseMusic(); 23 23 void resumeMusic(); 24 void trackSelect();25 24 static void musicDone(); 25 int volume; 26 int track_number; 27 int audio_rate, audio_channels, audio_buffers; 28 int done; 29 Uint16 audio_format; 26 30 27 31 protected: -
orxonox/branches/sound/sound/sound_test.cc
r2974 r2979 19 19 20 20 SoundControl* sound = NULL; 21 int counter = 0; 22 int through = 0; 21 int sfx_channel1 = -1; 22 int sfx_channel2 = -1; 23 int finished = 0; 23 24 24 25 SoundTest::SoundTest() { … … 26 27 } 27 28 28 29 29 SoundTest::~SoundTest() { 30 30 sound->deleteInstance(); 31 31 } 32 32 33 34 33 int main(void) { 35 34 SoundTest(); 36 35 SDL_Surface *screen; 36 SDL_Event event; 37 37 SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); 38 38 screen = SDL_SetVideoMode(320, 240, 0, 0); 39 sound->playOgg("music.ogg"); 40 while(!through) { 41 SDL_Delay(100); 42 if(counter >= 1000) { 43 through = 1; 39 while(!finished) { 40 while(SDL_PollEvent(&event)) { 41 switch(event.type) { 42 case SDL_QUIT: 43 finished = 1; 44 break; 45 case SDL_KEYDOWN: 46 case SDL_KEYUP: 47 handleKey(event.key); 48 break; 49 } 44 50 } 45 counter++;51 SDL_Delay(50); 46 52 } 47 53 SDL_Quit(); 48 54 } 55 56 void handleKey(SDL_KeyboardEvent key) { 57 switch(key.keysym.sym) { 58 case SDLK_a: 59 if(key.type == SDL_KEYDOWN) { 60 if(sfx_channel1 < 0) { 61 sfx_channel1 = sound->playWav("sound1.wav"); 62 } 63 } else { 64 Mix_HaltChannel(sfx_channel1); 65 sfx_channel1 = -1; 66 } 67 break; 68 case SDLK_s: 69 if(key.type == SDL_KEYDOWN) { 70 if(sfx_channel2 < 0) { 71 sfx_channel2 = sound->playWav("sound2.wav"); 72 } 73 } else { 74 Mix_HaltChannel(sfx_channel2); 75 sfx_channel2 = -1; 76 } 77 break; 78 case SDLK_m: 79 if(key.state == SDL_PRESSED) { 80 if(sound.music == NULL) { 81 sound->playOgg("music.ogg"); 82 } else { 83 Mix_HaltMusic(); 84 Mix_FreeMusic(music); 85 music = NULL; 86 } 87 } 88 break; 89 case SDLK_q: 90 finished = 1; 91 break; 92 } 93 } -
orxonox/branches/sound/sound/sound_test.h
r2974 r2979 12 12 ~SoundTest(); 13 13 int main (void); 14 void handleKey(SDL_KeyboardEvent key); 14 15 SoundControl* sound; 15 int counter; 16 int through; 16 int sfx_channel1; 17 int sfx_channel2; 18 int finished; 17 19 }; 18 20
Note: See TracChangeset
for help on using the changeset viewer.