Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3179 in orxonox.OLD for orxonox/branches/sound/src


Ignore:
Timestamp:
Dec 15, 2004, 3:40:54 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/sound: added files to source again, made it compile for widnows again.
Simon, if you arrive at a point where it is doing something usefull, we inject it into the trunk.

Location:
orxonox/branches/sound/src
Files:
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/src/Makefile

    r2964 r3179  
    1 # Makefile.in generated by automake 1.8.5 from Makefile.am.
     1# Makefile.in generated by automake 1.8.2 from Makefile.am.
    22# src/Makefile.  Generated from Makefile.in by configure.
    33
     
    4949CONFIG_HEADER = $(top_builddir)/config.h
    5050CONFIG_CLEAN_FILES =
    51 am__installdirs = "$(DESTDIR)$(bindir)"
     51am__installdirs = $(DESTDIR)$(bindir)
    5252binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
    5353PROGRAMS = $(bin_PROGRAMS)
     
    9090CTAGS = ctags
    9191DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
    92 ACLOCAL = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run aclocal-1.8
     92ACLOCAL = aclocal-1.8
    9393AMDEP_FALSE = #
    9494AMDEP_TRUE =
    95 AMTAR = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run tar
    96 AUTOCONF = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run autoconf
    97 AUTOHEADER = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run autoheader
    98 AUTOMAKE = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run automake-1.8
     95AMTAR = tar
     96AUTOCONF = autoconf
     97AUTOHEADER = autoheader
     98AUTOMAKE = automake-1.8
    9999AWK = gawk
    100100CC = gcc
     
    113113ECHO_T =
    114114EGREP = grep -E
    115 EXEEXT =
     115EXEEXT = .exe
    116116INSTALL_DATA = ${INSTALL} -m 644
    117117INSTALL_PROGRAM = ${INSTALL}
     
    120120LDFLAGS =
    121121LIBOBJS =
    122 LIBS = -lm  -lGL -lGLU -lSDL -lSDL_mixer -lpthread -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 
     122LIBS = -lm  -lopengl32 -lGLU32 -lmingw32 -lsdlmain -lsdl -lSDL_mixer -Lc:/Prog/Utils/MinGW/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl -liconv 
    123123LTLIBOBJS =
    124 MAKEINFO = ${SHELL} /home/bensch/svn/orxonox/branches/sound/missing --run makeinfo
    125 MSBITFIELDS =
     124MAKEINFO = makeinfo
     125MSBITFIELDS = -mms-bitfields
    126126OBJEXT = o
    127127PACKAGE = orxonox
     
    137137VERSION = 0.1-pre-alpha
    138138ac_ct_CC = gcc
    139 ac_ct_CXX =
     139ac_ct_CXX = g++
    140140ac_ct_STRIP =
    141141am__fastdepCC_FALSE = #
     
    153153includedir = ${prefix}/include
    154154infodir = ${prefix}/info
    155 install_sh = /home/bensch/svn/orxonox/branches/sound/install-sh
     155install_sh = /c/Documents and Settings/bensch/Desktop/svn/orxonox/branches/sound/install-sh
    156156libdir = ${exec_prefix}/lib
    157157libexecdir = ${exec_prefix}/libexec
     
    206206install-binPROGRAMS: $(bin_PROGRAMS)
    207207        @$(NORMAL_INSTALL)
    208         test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
     208        $(mkdir_p) $(DESTDIR)$(bindir)
    209209        @list='$(bin_PROGRAMS)'; for p in $$list; do \
    210210          p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
     
    212212          ; then \
    213213            f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
    214            echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
    215            $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
     214           echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
     215           $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
    216216          else :; fi; \
    217217        done
     
    221221        @list='$(bin_PROGRAMS)'; for p in $$list; do \
    222222          f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
    223           echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
    224           rm -f "$(DESTDIR)$(bindir)/$$f"; \
     223          echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
     224          rm -f $(DESTDIR)$(bindir)/$$f; \
    225225        done
    226226
     
    296296          $(AWK) '    { files[$$0] = 1; } \
    297297               END { for (i in files) print i; }'`; \
    298         if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
    299           test -n "$$unique" || unique=$$empty_fix; \
    300           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
    301             $$tags $$unique; \
    302         fi
     298        test -z "$(ETAGS_ARGS)$$tags$$unique" \
     299          || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
     300             $$tags $$unique
    303301ctags: CTAGS
    304302CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
     
    355353all-am: Makefile $(PROGRAMS) $(HEADERS)
    356354installdirs:
    357         for dir in "$(DESTDIR)$(bindir)"; do \
    358           test -z "$$dir" || $(mkdir_p) "$$dir"; \
    359         done
     355        $(mkdir_p) $(DESTDIR)$(bindir)
    360356install: install-am
    361357install-exec: install-exec-am
  • orxonox/branches/sound/src/Makefile.in

    r2964 r3179  
    1 # Makefile.in generated by automake 1.8.5 from Makefile.am.
     1# Makefile.in generated by automake 1.8.2 from Makefile.am.
    22# @configure_input@
    33
     
    4949CONFIG_HEADER = $(top_builddir)/config.h
    5050CONFIG_CLEAN_FILES =
    51 am__installdirs = "$(DESTDIR)$(bindir)"
     51am__installdirs = $(DESTDIR)$(bindir)
    5252binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
    5353PROGRAMS = $(bin_PROGRAMS)
     
    206206install-binPROGRAMS: $(bin_PROGRAMS)
    207207        @$(NORMAL_INSTALL)
    208         test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
     208        $(mkdir_p) $(DESTDIR)$(bindir)
    209209        @list='$(bin_PROGRAMS)'; for p in $$list; do \
    210210          p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
     
    212212          ; then \
    213213            f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
    214            echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
    215            $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
     214           echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
     215           $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
    216216          else :; fi; \
    217217        done
     
    221221        @list='$(bin_PROGRAMS)'; for p in $$list; do \
    222222          f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
    223           echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
    224           rm -f "$(DESTDIR)$(bindir)/$$f"; \
     223          echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
     224          rm -f $(DESTDIR)$(bindir)/$$f; \
    225225        done
    226226
     
    296296          $(AWK) '    { files[$$0] = 1; } \
    297297               END { for (i in files) print i; }'`; \
    298         if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
    299           test -n "$$unique" || unique=$$empty_fix; \
    300           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
    301             $$tags $$unique; \
    302         fi
     298        test -z "$(ETAGS_ARGS)$$tags$$unique" \
     299          || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
     300             $$tags $$unique
    303301ctags: CTAGS
    304302CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
     
    355353all-am: Makefile $(PROGRAMS) $(HEADERS)
    356354installdirs:
    357         for dir in "$(DESTDIR)$(bindir)"; do \
    358           test -z "$$dir" || $(mkdir_p) "$$dir"; \
    359         done
     355        $(mkdir_p) $(DESTDIR)$(bindir)
    360356install: install-am
    361357install-exec: install-exec-am
  • orxonox/branches/sound/src/sound_control.cc

    r2972 r3179  
    1818using namespace std;
    1919
    20 // global variables
    21 SoundControl* SoundControl::instance = NULL; // singleton reference
     20int sfx_channel1 = -1;
     21int sfx_channel2 = -1;
     22int finished = 0;
     23SoundControl* SoundControl::sound = SoundControl::getInstance();
     24SoundControl* SoundControl::instance = 0;
    2225int volume = SDL_MIX_MAXVOLUME;
    23 int done = 0;
    2426int track_number = 1;
    25 static Mix_Music* music = NULL;
    26 int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 16384, bits = 0;
     27Mix_Music* music = NULL;
     28int audio_rate = 44100, audio_channels = MIX_DEFAULT_CHANNELS,
     29audio_buffers = 16384, bits = 0;
    2730Uint16 audio_format = MIX_DEFAULT_FORMAT;
     31SDL_Event event;
    2832
    2933
    3034/**
    3135    \brief standard constructor
    32    
    33     This constructor builds a SoundControl Object, which waits for callers.
     36    This constructor builds a SoundControl Object and initialises it .
    3437    All sound output is handled by this singleton object.
    3538*/
    36 SoundControl::SoundControl () {
    37 
    38   /*
    39   initializing sound and calling Mix_OpenAudio
    40   if(SDL_Init(SDL_INIT_AUDIO)<0){
     39SoundControl::SoundControl() {
     40  if(SDL_Init(SDL_INIT_AUDIO)<0) {
    4141    printf("SDL_Init: INIT_AUDIO error.\n");
    4242  }
    43   */
    44  
    45   if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){
     43  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
    4644    printf("Mix_OpenAudio: Failed to open audio!\n");
    4745  }
    48  
    4946  initialise();
    5047}
    5148
    52 
    5349/**
    5450    \brief Default destructor
    5551*/
    56 SoundControl::~SoundControl () {
     52SoundControl::~SoundControl() {
    5753}
    5854
    5955/**
    60    \brief Returns a reference to the singleton
     56   \brief Returns a reference to the SoundControl singleton
    6157*/
    6258SoundControl* SoundControl::getInstance() {
    63   if (instance == NULL) {
     59  if (instance == 0) {
    6460    instance = new SoundControl;
    6561  }
     
    6864
    6965void SoundControl::deleteInstance() {
    70   delete instance;
    71   instance = NULL;
    72 }
    73 
    74 /**
    75     \brief Is called by SoundControl object to initiate all values
     66}
     67
     68/**
     69    \brief Is called by SoundControl object to initiate all values and to output some text
    7670*/
    7771void SoundControl::initialise() {
    78  
    79   // Print some info
    8072  Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
    8173  bits=audio_format&0xFF;
     
    8476}
    8577
    86 
    87 /**
    88     \brief Sets the number of output Channels (should not be used)
    89 */
    90 void SoundControl::setNumberOfChannels (int number_of_channels) {
     78/**
     79    \brief Sets the number of output Channels
     80*/
     81void SoundControl::setNumberOfChannels(int number_of_channels) {
    9182  Mix_AllocateChannels(number_of_channels);
    9283}
    9384
    94 
    95 /**
    96     \brief May be called from any WorldEntity to play a .xm file
     85/**
     86    \brief Static function to play a .xm file
    9787    \param filename: self-explanatory
    9888*/
    99 int SoundControl::playMod (char* fileName) {
     89void SoundControl::playMod(char* fileName) {
    10090  Mix_Chunk* chunk = NULL;
    10191  chunk = Mix_LoadWAV(fileName);
     
    10595}
    10696
    107 
    108 /**
    109     \brief May be called from any WorldEntity to play a .wav file
     97/**
     98    \brief Static function to play a .wav file
    11099    \param filename: self-explanatory
    111100*/
    112 int SoundControl::playWav (char* fileName) {
     101void SoundControl::playWav(char* fileName) {
    113102  Mix_Chunk* chunk = NULL;
    114103  chunk = Mix_LoadWAV(fileName);
     
    118107}
    119108
    120 
    121 /**
    122     \brief May be called from any WorldEntity to play a .ogg file
     109/**
     110    \brief Static function to play an .ogg file
    123111    \param filename: self-explanatory
    124112*/
    125 int SoundControl::playOgg (char* fileName) {
     113void SoundControl::playOgg(char* fileName) {
    126114  Mix_Music* music = NULL;
    127115  music = Mix_LoadMUS(fileName);
    128   if(Mix_PlayMusic(music, 1) == -1){
     116  if(Mix_PlayMusic(music, 1) == -1) {
    129117    printf("Mix_PlayMusic: %s\n",Mix_GetError());
    130118  }
     
    132120}
    133121
    134 
    135122/**
    136123    \brief Heightens the overall volume of output
    137124*/
    138 void SoundControl::volumeUp () {
     125void SoundControl::volumeUp() {
    139126  volume = (volume + 1) << 1;
    140127  if(volume > SDL_MIX_MAXVOLUME)
     
    147134    \brief Lowers the overall volume of output
    148135*/ 
    149 void SoundControl::volumeDown () {
     136void SoundControl::volumeDown() {
    150137  volume >>= 1;
    151138  Mix_VolumeMusic(volume);
    152139}
    153140
    154 
    155141/**
    156142    \brief Rewinds music to the beginning
    157143*/ 
    158 void SoundControl::trackRewind () {
     144void SoundControl::trackRewind() {
    159145  Mix_RewindMusic();
    160146}
    161147
    162 
    163148/**
    164149    \brief Rewinds the music 5 seconds
    165150*/ 
    166 void SoundControl::forwardMusic () {
     151void SoundControl::forwardMusic() {
    167152  Mix_SetMusicPosition(+5);
    168153}
    169 
    170154
    171155/**
     
    176160}
    177161
    178 
    179162/**
    180163    \brief Pauses music output
    181164*/
    182 void SoundControl::pauseMusic () {
     165void SoundControl::pauseMusic() {
    183166  Mix_PauseMusic();
    184167}
    185168
    186 
    187 /**
    188     \brief this function pauses music output
    189 */
    190 void SoundControl::resumeMusic () {
     169/**
     170    \brief Pauses music output
     171*/
     172void SoundControl::resumeMusic() {
    191173  Mix_ResumeMusic();
    192174}
    193175
    194176/**
    195     \brief Selects the track of all orxonox tracks
    196 */
    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 
     177    \brief Fades in music
     178*/
     179void fadeInMusic(int time) {
     180
     181}
     182
     183/**
     184    \brief Fades out music
     185*/
     186void SoundControl::fadeOutMusic(int time) {
     187
     188}
    244189
    245190/**
     
    251196  music = NULL;
    252197}
     198
     199/**
     200    \brief Handles input events
     201*/
     202void SoundControl::handleKey(SDL_KeyboardEvent key) {
     203  switch(key.keysym.sym) {
     204  case SDLK_a:
     205    if(key.type == SDL_KEYDOWN) {
     206      if(sfx_channel1 < 0) {
     207        sfx_channel1 = 1;
     208        sound->playWav("sound1.wav");
     209      }
     210    } else {
     211      Mix_HaltChannel(sfx_channel1);
     212      sfx_channel1 = -1;
     213    }
     214    break;
     215  case SDLK_s:
     216    if(key.type == SDL_KEYDOWN) {
     217      if(sfx_channel2 < 0) {
     218        sfx_channel2 = 1;
     219        sound->playWav("sound2.wav");
     220      }
     221    } else {
     222      Mix_HaltChannel(sfx_channel2);
     223      sfx_channel2 = -1;
     224    }
     225    break;
     226  case SDLK_m:
     227    if(key.state == SDL_PRESSED) {
     228      sound->playOgg("music.ogg");
     229    }
     230    break;
     231  case SDLK_q:
     232    finished = 1;
     233    break;
     234  default:
     235    break;
     236  }
     237}
     238
     239int SoundControl::main(int argc, char* argv[]) {
     240  SDL_Surface* screen;
     241  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
     242  screen = SDL_SetVideoMode(320, 240, 0, 0);
     243  while(!finished) {
     244    while(SDL_PollEvent(&event)) {
     245      switch(event.type) {
     246      case SDL_QUIT:
     247        finished = 1;
     248        break;
     249      case SDL_KEYDOWN:
     250      case SDL_KEYUP:
     251        SoundControl::handleKey(event.key);
     252        break;
     253      default:
     254        break;
     255      }
     256    }
     257    SDL_Delay(50);
     258  }
     259  deleteInstance();
     260  SDL_Quit();
     261  return 0;
     262}
  • orxonox/branches/sound/src/sound_control.h

    r2972 r3179  
    77
    88class SoundControl {
    9 
    109 public:
    1110  static SoundControl* getInstance();
    1211  static void deleteInstance();
     12 
    1313  void setNumberOfChannels(int number_of_channels);
    14   int playMod(char* filename);
    15   int playWav(char* filename);
    16   int playOgg(char* filename);
     14  static void playMod(char* filename);
     15  static void playWav(char* filename);
     16  static void playOgg(char* filename);
    1717  void volumeUp();
    1818  void volumeDown();
     
    2222  void pauseMusic();
    2323  void resumeMusic();
    24   void trackSelect();
     24  void fadeInMusic(int time);
     25  void fadeOutMusic(int time);
    2526  static void musicDone();
     27 
     28  void handleKey(SDL_KeyboardEvent key);
     29  int main(int argc, char* argv[]);
     30 
     31  static SoundControl* sound;
     32  int volume;
     33  int track_number;
     34  int audio_rate, audio_channels, audio_buffers;
     35  int done;
     36  Uint16 audio_format;
     37  int sfx_channel1;
     38  int sfx_channel2;
     39  int finished;
    2640
    27 protected:
    28   void initialise();
     41 protected:
    2942  SoundControl();
    3043  ~SoundControl();
     44  void initialise();
    3145
    32 private:
     46 private:
    3347  static SoundControl* instance;
    3448};
  • orxonox/branches/sound/src/sound_test.cc

    r2972 r3179  
    3232
    3333
    34 int main(void) {
     34int main(int argc, char *argv[]) {
    3535  SoundTest();
    3636  SDL_Surface *screen;
Note: See TracChangeset for help on using the changeset viewer.