Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2854 in orxonox.OLD for orxonox/branches/sound


Ignore:
Timestamp:
Nov 14, 2004, 4:44:31 PM (20 years ago)
Author:
simon
Message:

/branches/sound: finally a running version. To test, you can switch the parameters in the test class sound_test. A .ogg file named music.ogg from the directory . is played. The test class is really ugly, I know.

Location:
orxonox/branches/sound
Files:
1 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/config.h.in

    r2627 r2854  
    3434/* Define to 1 if you have the <SDL/SDL.h> header file. */
    3535#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
    3639
    3740/* Define to 1 if you have the `sqrt' function. */
  • orxonox/branches/sound/configure

    r2627 r2854  
    43934393    fi
    43944394fi
     4395
     4396
     4397for ac_header in SDL/SDL_mixer.h
     4398do
     4399as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
     4400if eval "test \"\${$as_ac_Header+set}\" = set"; then
     4401  echo "$as_me:$LINENO: checking for $ac_header" >&5
     4402echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     4403if eval "test \"\${$as_ac_Header+set}\" = set"; then
     4404  echo $ECHO_N "(cached) $ECHO_C" >&6
     4405fi
     4406echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     4407echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     4408else
     4409  # Is the header compilable?
     4410echo "$as_me:$LINENO: checking $ac_header usability" >&5
     4411echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
     4412cat >conftest.$ac_ext <<_ACEOF
     4413/* confdefs.h.  */
     4414_ACEOF
     4415cat confdefs.h >>conftest.$ac_ext
     4416cat >>conftest.$ac_ext <<_ACEOF
     4417/* end confdefs.h.  */
     4418$ac_includes_default
     4419#include <$ac_header>
     4420_ACEOF
     4421rm -f conftest.$ac_objext
     4422if { (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
     4444else
     4445  echo "$as_me: failed program was:" >&5
     4446sed 's/^/| /' conftest.$ac_ext >&5
     4447
     4448ac_header_compiler=no
     4449fi
     4450rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     4451echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
     4452echo "${ECHO_T}$ac_header_compiler" >&6
     4453
     4454# Is the header present?
     4455echo "$as_me:$LINENO: checking $ac_header presence" >&5
     4456echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
     4457cat >conftest.$ac_ext <<_ACEOF
     4458/* confdefs.h.  */
     4459_ACEOF
     4460cat confdefs.h >>conftest.$ac_ext
     4461cat >>conftest.$ac_ext <<_ACEOF
     4462/* end confdefs.h.  */
     4463#include <$ac_header>
     4464_ACEOF
     4465if { (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
     4479else
     4480  ac_cpp_err=yes
     4481fi
     4482if test -z "$ac_cpp_err"; then
     4483  ac_header_preproc=yes
     4484else
     4485  echo "$as_me: failed program was:" >&5
     4486sed 's/^/| /' conftest.$ac_ext >&5
     4487
     4488  ac_header_preproc=no
     4489fi
     4490rm -f conftest.err conftest.$ac_ext
     4491echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
     4492echo "${ECHO_T}$ac_header_preproc" >&6
     4493
     4494# So?  What about this header?
     4495case $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
     4498echo "$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
     4500echo "$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
     4505echo "$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
     4507echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
     4508    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
     4509echo "$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
     4511echo "$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
     4513echo "$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
     4515echo "$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    ;;
     4525esac
     4526echo "$as_me:$LINENO: checking for $ac_header" >&5
     4527echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     4528if eval "test \"\${$as_ac_Header+set}\" = set"; then
     4529  echo $ECHO_N "(cached) $ECHO_C" >&6
     4530else
     4531  eval "$as_ac_Header=\$ac_header_preproc"
     4532fi
     4533echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     4534echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     4535
     4536fi
     4537if 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
     4542else
     4543  { { echo "$as_me:$LINENO: error: cannot find sdlmixer headers" >&5
     4544echo "$as_me: error: cannot find sdlmixer headers" >&2;}
     4545   { (exit 1); exit 1; }; }
     4546fi
     4547
     4548done
     4549
     4550
     4551LIBS="$LIBS -lSDL_mixer"
    43954552
    43964553# FIXME: Replace `main' with a function in `-lOSMesa':
  • orxonox/branches/sound/configure.ac

    r2627 r2854  
    7777fi
    7878
     79AC_CHECK_HEADERS(SDL/SDL_mixer.h ,,
     80      [AC_MSG_ERROR([cannot find sdlmixer headers]) ])
     81
     82LIBS="$LIBS -lSDL_mixer"
     83
    7984# FIXME: Replace `main' with a function in `-lOSMesa':
    8085AC_CHECK_LIB([OSMesa], [main])
  • orxonox/branches/sound/src/Makefile.am

    r2636 r2854  
    55
    66
    7 bin_PROGRAMS=orxonox
     7bin_PROGRAMS=orxonox sound
    88orxonox_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
     10sound_SOURCES=sound_test.cc sound_control.cc
    911
    1012noinst_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  
    116116
    117117#"-O3 -pedantic -fPIC -ffast-math -I/usr/X11R6/include"
    118 bin_PROGRAMS = orxonox
     118bin_PROGRAMS = orxonox sound
    119119orxonox_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
     121sound_SOURCES = sound_test.cc sound_control.cc
    120122
    121123noinst_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
     
    125127CONFIG_HEADER = $(top_builddir)/config.h
    126128CONFIG_CLEAN_FILES =
    127 bin_PROGRAMS = orxonox$(EXEEXT)
     129bin_PROGRAMS = orxonox$(EXEEXT) sound$(EXEEXT)
    128130PROGRAMS = $(bin_PROGRAMS)
    129131
     
    138140orxonox_DEPENDENCIES =
    139141orxonox_LDFLAGS =
     142am_sound_OBJECTS = sound_test.$(OBJEXT) sound_control.$(OBJEXT)
     143sound_OBJECTS = $(am_sound_OBJECTS)
     144sound_LDADD = $(LDADD)
     145sound_DEPENDENCIES =
     146sound_LDFLAGS =
    140147
    141148DEFAULT_INCLUDES =  -I. -I$(srcdir) -I$(top_builddir)
     
    148155@AMDEP_TRUE@    ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \
    149156@AMDEP_TRUE@    ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/player.Po \
     157@AMDEP_TRUE@    ./$(DEPDIR)/sound_control.Po \
     158@AMDEP_TRUE@    ./$(DEPDIR)/sound_test.Po \
    150159@AMDEP_TRUE@    ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/track.Po \
    151160@AMDEP_TRUE@    ./$(DEPDIR)/vector.Po ./$(DEPDIR)/world.Po \
     
    156165CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
    157166        -o $@
    158 DIST_SOURCES = $(orxonox_SOURCES)
     167DIST_SOURCES = $(orxonox_SOURCES) $(sound_SOURCES)
    159168HEADERS = $(noinst_HEADERS)
    160169
    161170DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.in INSTALL \
    162171        Makefile.am
    163 SOURCES = $(orxonox_SOURCES)
     172SOURCES = $(orxonox_SOURCES) $(sound_SOURCES)
    164173
    165174all: all-am
     
    199208        @rm -f orxonox$(EXEEXT)
    200209        $(CXXLINK) $(orxonox_LDFLAGS) $(orxonox_OBJECTS) $(orxonox_LDADD) $(LIBS)
     210sound$(EXEEXT): $(sound_OBJECTS) $(sound_DEPENDENCIES)
     211        @rm -f sound$(EXEEXT)
     212        $(CXXLINK) $(sound_LDFLAGS) $(sound_OBJECTS) $(sound_LDADD) $(LIBS)
    201213
    202214mostlyclean-compile:
     
    217229@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@
    218230@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@
    219233@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@
    220234@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/track.Po@am__quote@
  • orxonox/branches/sound/src/sound_control.cc

    r2838 r2854  
    1515
    1616#include "sound_control.h"
    17 #include <string.h>
    18 #include "SDL_mixer.h"
    1917
    2018using namespace std;
    2119
    2220// global variables
    23 
    24 SoundControl* SoundControl::instance = 0; // singleton reference
    25 int volume = SDL_MIX_MAXVOLUME; // volume
    26 int done = 0; //
     21SoundControl* SoundControl::instance = NULL; // singleton reference
     22int volume = SDL_MIX_MAXVOLUME;
     23int done = 0;
    2724int track_number = 1;
    28 Mix_Music* music = NULL;
     25static Mix_Music* music = NULL;
     26int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 16384, bits = 0;
     27Uint16 audio_format = MIX_DEFAULT_FORMAT;
     28
    2929
    3030/**
     
    3535*/
    3636SoundControl::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
    4340  if(SDL_Init(SDL_INIT_AUDIO)<0){
    44     printf("SDL_Init: \n");
    45     exit(1);
     41    printf("SDL_Init: INIT_AUDIO error.\n");
    4642  }
     43  */
    4744 
    4845  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");
    5147  }
    5248 
     
    5652
    5753/**
    58     \brief Destructor for the singleton instance
     54    \brief Default destructor
    5955*/
    6056SoundControl::~SoundControl () {
    61   delete instance;
    62   instance = 0;
    6357}
    6458
     
    6761*/
    6862SoundControl* SoundControl::getInstance() {
    69   if (instance == 0) {
     63  if (instance == NULL) {
    7064    instance = new SoundControl;
    7165  }
     
    7468
    7569void SoundControl::deleteInstance() {
    76   ~SoundControl();
     70  delete instance;
     71  instance = NULL;
    7772}
    7873
     
    186181*/
    187182void SoundControl::pauseMusic () {
    188   Mix_PauseMusic()
     183  Mix_PauseMusic();
    189184}
    190185
     
    194189*/
    195190void SoundControl::resumeMusic () {
    196   Mix_ResumeMusic()
     191  Mix_ResumeMusic();
    197192}
    198193
     
    200195    \brief Selects the track of all orxonox tracks
    201196*/
    202 void SoundControl::trackSelect () {
     197void SoundControl::trackSelect() {
    203198  switch (track_number) {
    204199  case 1:
     
    219214    music = Mix_LoadMUS("luke_grey_orxonox3.ogg");
    220215    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;
    225220  case 4:
    226221    music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg");
     
    239234  case 6:
    240235    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;
    246241  }
    247242}
     
    251246    \brief Hooked by playOgg at end of .ogg playback
    252247*/
    253 void SoundControl::musicDone () {
    254   track_number++;
     248void SoundControl::musicDone() {
    255249  Mix_HaltMusic();
    256250  Mix_FreeMusic(music);
  • orxonox/branches/sound/src/sound_control.h

    r2838 r2854  
    22#define SOUNDCONTROL_CLASS_H
    33
    4 #include "data_tank.h"
     4#include "SDL/SDL.h"
     5#include "SDL/SDL_mixer.h"
     6#include <stdio.h>
    57
    68class SoundControl {
     
    911  static SoundControl* getInstance();
    1012  static void deleteInstance();
    11   void setNumberOfChannels(int number_of channels);
     13  void setNumberOfChannels(int number_of_channels);
    1214  int playMod(char* filename);
    1315  int playWav(char* filename);
     
    2123  void resumeMusic();
    2224  void trackSelect();
     25  static void musicDone();
    2326
    2427protected:
     
    2932private:
    3033  static SoundControl* instance;
    31 
    32 }
     34};
    3335
    3436#endif
  • orxonox/branches/sound/src/sound_test.cc

    r2838 r2854  
    1414*/
    1515
    16 
    1716#include "sound_test.h"
    18 #include "SDL.h"
    19 #include "SDL_mixer.h"
    2017
    2118using namespace std;
    2219
    23 SoundControl* test;
     20SoundControl* sound = NULL;
     21int counter = 0;
     22int through = 0;
    2423
    25 SoundTest::SoundTest () {
    26   test = SoundControl::getInstance();
     24SoundTest::SoundTest() {
     25  sound = SoundControl::getInstance();
    2726}
    2827
    2928
    30 SoundTest::~SoundTest () {
    31  
     29SoundTest::~SoundTest() {
     30  sound->deleteInstance();
    3231}
    3332
    3433
    35 void main (void) {
     34int main(void) {
     35  SoundTest();
    3636  SDL_Surface *screen;
    37   SDL_Init(SDL_INIT_VIDEO);
     37  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
    3838  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();
    4348}
  • orxonox/branches/sound/src/sound_test.h

    r2838 r2854  
    1 
    21#ifndef SOUND_TEST_H
    32#define SOUND_TEST_H
    43
    5 #include "data_tank.h"
    6 
     4#include "sound_control.h"
     5#include "SDL/SDL.h"
     6#include "SDL/SDL_mixer.h"
    77
    88class SoundTest {
    99
    1010 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;
    1417};
    1518
Note: See TracChangeset for help on using the changeset viewer.