Changeset 2854 in orxonox.OLD for orxonox/branches/sound
- Timestamp:
- Nov 14, 2004, 4:44:31 PM (20 years ago)
- Location:
- orxonox/branches/sound
- Files:
-
- 1 added
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound/config.h.in
r2627 r2854 34 34 /* Define to 1 if you have the <SDL/SDL.h> header file. */ 35 35 #undef HAVE_SDL_SDL_H 36 37 /* Define to 1 if you have the <SDL/SDL_mixer.h> header file. */ 38 #undef HAVE_SDL_SDL_MIXER_H 36 39 37 40 /* Define to 1 if you have the `sqrt' function. */ -
orxonox/branches/sound/configure
r2627 r2854 4393 4393 fi 4394 4394 fi 4395 4396 4397 for ac_header in SDL/SDL_mixer.h 4398 do 4399 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 4400 if eval "test \"\${$as_ac_Header+set}\" = set"; then 4401 echo "$as_me:$LINENO: checking for $ac_header" >&5 4402 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 4403 if eval "test \"\${$as_ac_Header+set}\" = set"; then 4404 echo $ECHO_N "(cached) $ECHO_C" >&6 4405 fi 4406 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 4407 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 4408 else 4409 # Is the header compilable? 4410 echo "$as_me:$LINENO: checking $ac_header usability" >&5 4411 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 4412 cat >conftest.$ac_ext <<_ACEOF 4413 /* confdefs.h. */ 4414 _ACEOF 4415 cat confdefs.h >>conftest.$ac_ext 4416 cat >>conftest.$ac_ext <<_ACEOF 4417 /* end confdefs.h. */ 4418 $ac_includes_default 4419 #include <$ac_header> 4420 _ACEOF 4421 rm -f conftest.$ac_objext 4422 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 4423 (eval $ac_compile) 2>conftest.er1 4424 ac_status=$? 4425 grep -v '^ *+' conftest.er1 >conftest.err 4426 rm -f conftest.er1 4427 cat conftest.err >&5 4428 echo "$as_me:$LINENO: \$? = $ac_status" >&5 4429 (exit $ac_status); } && 4430 { ac_try='test -z "$ac_c_werror_flag" 4431 || test ! -s conftest.err' 4432 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 4433 (eval $ac_try) 2>&5 4434 ac_status=$? 4435 echo "$as_me:$LINENO: \$? = $ac_status" >&5 4436 (exit $ac_status); }; } && 4437 { ac_try='test -s conftest.$ac_objext' 4438 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 4439 (eval $ac_try) 2>&5 4440 ac_status=$? 4441 echo "$as_me:$LINENO: \$? = $ac_status" >&5 4442 (exit $ac_status); }; }; then 4443 ac_header_compiler=yes 4444 else 4445 echo "$as_me: failed program was:" >&5 4446 sed 's/^/| /' conftest.$ac_ext >&5 4447 4448 ac_header_compiler=no 4449 fi 4450 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 4451 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 4452 echo "${ECHO_T}$ac_header_compiler" >&6 4453 4454 # Is the header present? 4455 echo "$as_me:$LINENO: checking $ac_header presence" >&5 4456 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 4457 cat >conftest.$ac_ext <<_ACEOF 4458 /* confdefs.h. */ 4459 _ACEOF 4460 cat confdefs.h >>conftest.$ac_ext 4461 cat >>conftest.$ac_ext <<_ACEOF 4462 /* end confdefs.h. */ 4463 #include <$ac_header> 4464 _ACEOF 4465 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 4466 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 4467 ac_status=$? 4468 grep -v '^ *+' conftest.er1 >conftest.err 4469 rm -f conftest.er1 4470 cat conftest.err >&5 4471 echo "$as_me:$LINENO: \$? = $ac_status" >&5 4472 (exit $ac_status); } >/dev/null; then 4473 if test -s conftest.err; then 4474 ac_cpp_err=$ac_c_preproc_warn_flag 4475 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag 4476 else 4477 ac_cpp_err= 4478 fi 4479 else 4480 ac_cpp_err=yes 4481 fi 4482 if test -z "$ac_cpp_err"; then 4483 ac_header_preproc=yes 4484 else 4485 echo "$as_me: failed program was:" >&5 4486 sed 's/^/| /' conftest.$ac_ext >&5 4487 4488 ac_header_preproc=no 4489 fi 4490 rm -f conftest.err conftest.$ac_ext 4491 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 4492 echo "${ECHO_T}$ac_header_preproc" >&6 4493 4494 # So? What about this header? 4495 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 4496 yes:no: ) 4497 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 4498 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 4499 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 4500 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 4501 ac_header_preproc=yes 4502 ;; 4503 no:yes:* ) 4504 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 4505 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 4506 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 4507 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 4508 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 4509 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 4510 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 4511 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 4512 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 4513 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 4514 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 4515 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 4516 ( 4517 cat <<\_ASBOX 4518 ## ------------------------------------------- ## 4519 ## Report this to orxonox-dev@mail.datacore.ch ## 4520 ## ------------------------------------------- ## 4521 _ASBOX 4522 ) | 4523 sed "s/^/$as_me: WARNING: /" >&2 4524 ;; 4525 esac 4526 echo "$as_me:$LINENO: checking for $ac_header" >&5 4527 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 4528 if eval "test \"\${$as_ac_Header+set}\" = set"; then 4529 echo $ECHO_N "(cached) $ECHO_C" >&6 4530 else 4531 eval "$as_ac_Header=\$ac_header_preproc" 4532 fi 4533 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 4534 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 4535 4536 fi 4537 if test `eval echo '${'$as_ac_Header'}'` = yes; then 4538 cat >>confdefs.h <<_ACEOF 4539 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 4540 _ACEOF 4541 4542 else 4543 { { echo "$as_me:$LINENO: error: cannot find sdlmixer headers" >&5 4544 echo "$as_me: error: cannot find sdlmixer headers" >&2;} 4545 { (exit 1); exit 1; }; } 4546 fi 4547 4548 done 4549 4550 4551 LIBS="$LIBS -lSDL_mixer" 4395 4552 4396 4553 # FIXME: Replace `main' with a function in `-lOSMesa': -
orxonox/branches/sound/configure.ac
r2627 r2854 77 77 fi 78 78 79 AC_CHECK_HEADERS(SDL/SDL_mixer.h ,, 80 [AC_MSG_ERROR([cannot find sdlmixer headers]) ]) 81 82 LIBS="$LIBS -lSDL_mixer" 83 79 84 # FIXME: Replace `main' with a function in `-lOSMesa': 80 85 AC_CHECK_LIB([OSMesa], [main]) -
orxonox/branches/sound/src/Makefile.am
r2636 r2854 5 5 6 6 7 bin_PROGRAMS=orxonox 7 bin_PROGRAMS=orxonox sound 8 8 orxonox_SOURCES=orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc 9 10 sound_SOURCES=sound_test.cc sound_control.cc 9 11 10 12 noinst_HEADERS=ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h -
orxonox/branches/sound/src/Makefile.in
r2640 r2854 116 116 117 117 #"-O3 -pedantic -fPIC -ffast-math -I/usr/X11R6/include" 118 bin_PROGRAMS = orxonox 118 bin_PROGRAMS = orxonox sound 119 119 orxonox_SOURCES = orxonox.cc world.cc player.cc data_tank.cc world_entity.cc vector.cc camera.cc collision.cc command_node.cc ini_parser.cc keynames.cc track.cc base_entity.cc game_loader.cc campaign.cc story_entity.cc 120 121 sound_SOURCES = sound_test.cc sound_control.cc 120 122 121 123 noinst_HEADERS = ability.h data_tank.h npc.h stdincl.h ai.h environment.h orxonox.h synchronisable.h base_entity.h error.h player.h track.h camera.h ini_parser.h power_up.h vector.h collision.h keynames.h proto_class.h world.h command_node.h list.h shoot_laser.h world_entity.h coordinates.h message_structures.h shoot_rocket.h … … 125 127 CONFIG_HEADER = $(top_builddir)/config.h 126 128 CONFIG_CLEAN_FILES = 127 bin_PROGRAMS = orxonox$(EXEEXT) 129 bin_PROGRAMS = orxonox$(EXEEXT) sound$(EXEEXT) 128 130 PROGRAMS = $(bin_PROGRAMS) 129 131 … … 138 140 orxonox_DEPENDENCIES = 139 141 orxonox_LDFLAGS = 142 am_sound_OBJECTS = sound_test.$(OBJEXT) sound_control.$(OBJEXT) 143 sound_OBJECTS = $(am_sound_OBJECTS) 144 sound_LDADD = $(LDADD) 145 sound_DEPENDENCIES = 146 sound_LDFLAGS = 140 147 141 148 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) … … 148 155 @AMDEP_TRUE@ ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \ 149 156 @AMDEP_TRUE@ ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/player.Po \ 157 @AMDEP_TRUE@ ./$(DEPDIR)/sound_control.Po \ 158 @AMDEP_TRUE@ ./$(DEPDIR)/sound_test.Po \ 150 159 @AMDEP_TRUE@ ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/track.Po \ 151 160 @AMDEP_TRUE@ ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \ … … 156 165 CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ 157 166 -o $@ 158 DIST_SOURCES = $(orxonox_SOURCES) 167 DIST_SOURCES = $(orxonox_SOURCES) $(sound_SOURCES) 159 168 HEADERS = $(noinst_HEADERS) 160 169 161 170 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in INSTALL \ 162 171 Makefile.am 163 SOURCES = $(orxonox_SOURCES) 172 SOURCES = $(orxonox_SOURCES) $(sound_SOURCES) 164 173 165 174 all: all-am … … 199 208 @rm -f orxonox$(EXEEXT) 200 209 $(CXXLINK) $(orxonox_LDFLAGS) $(orxonox_OBJECTS) $(orxonox_LDADD) $(LIBS) 210 sound$(EXEEXT): $(sound_OBJECTS) $(sound_DEPENDENCIES) 211 @rm -f sound$(EXEEXT) 212 $(CXXLINK) $(sound_LDFLAGS) $(sound_OBJECTS) $(sound_LDADD) $(LIBS) 201 213 202 214 mostlyclean-compile: … … 217 229 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@ 218 230 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/player.Po@am__quote@ 231 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_control.Po@am__quote@ 232 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_test.Po@am__quote@ 219 233 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@ 220 234 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track.Po@am__quote@ -
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); -
orxonox/branches/sound/src/sound_control.h
r2838 r2854 2 2 #define SOUNDCONTROL_CLASS_H 3 3 4 #include "data_tank.h" 4 #include "SDL/SDL.h" 5 #include "SDL/SDL_mixer.h" 6 #include <stdio.h> 5 7 6 8 class SoundControl { … … 9 11 static SoundControl* getInstance(); 10 12 static void deleteInstance(); 11 void setNumberOfChannels(int number_of 13 void setNumberOfChannels(int number_of_channels); 12 14 int playMod(char* filename); 13 15 int playWav(char* filename); … … 21 23 void resumeMusic(); 22 24 void trackSelect(); 25 static void musicDone(); 23 26 24 27 protected: … … 29 32 private: 30 33 static SoundControl* instance; 31 32 } 34 }; 33 35 34 36 #endif -
orxonox/branches/sound/src/sound_test.cc
r2838 r2854 14 14 */ 15 15 16 17 16 #include "sound_test.h" 18 #include "SDL.h"19 #include "SDL_mixer.h"20 17 21 18 using namespace std; 22 19 23 SoundControl* test; 20 SoundControl* sound = NULL; 21 int counter = 0; 22 int through = 0; 24 23 25 SoundTest::SoundTest 26 test= SoundControl::getInstance();24 SoundTest::SoundTest() { 25 sound = SoundControl::getInstance(); 27 26 } 28 27 29 28 30 SoundTest::~SoundTest 31 29 SoundTest::~SoundTest() { 30 sound->deleteInstance(); 32 31 } 33 32 34 33 35 void main (void) { 34 int main(void) { 35 SoundTest(); 36 36 SDL_Surface *screen; 37 SDL_Init(SDL_INIT_VIDEO );37 SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); 38 38 screen = SDL_SetVideoMode(320, 240, 0, 0); 39 SoundControl* sound = new SoundControl; 40 sound.SoundControl(); 41 sound->playOgg(music.ogg); 42 sound.~SoundControl(); 39 sound->playOgg("music.ogg"); 40 while(!through) { 41 SDL_Delay(100); 42 if(counter >= 1000) { 43 through = 1; 44 } 45 counter++; 46 } 47 SDL_Quit(); 43 48 } -
orxonox/branches/sound/src/sound_test.h
r2838 r2854 1 2 1 #ifndef SOUND_TEST_H 3 2 #define SOUND_TEST_H 4 3 5 #include "data_tank.h" 6 4 #include "sound_control.h" 5 #include "SDL/SDL.h" 6 #include "SDL/SDL_mixer.h" 7 7 8 8 class SoundTest { 9 9 10 10 public: 11 SoundTest (); 12 ~SoundTest (); 13 void main (void); 11 SoundTest(); 12 ~SoundTest(); 13 int main (void); 14 SoundControl* sound; 15 int counter; 16 int through; 14 17 }; 15 18
Note: See TracChangeset
for help on using the changeset viewer.