Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3887 in orxonox.OLD


Ignore:
Timestamp:
Apr 19, 2005, 12:28:55 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added some classes to handle Audio

Location:
orxonox/branches/sound_engine/src
Files:
1 added
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound_engine/src/Makefile.am

    r3869 r3887  
    88AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics
    99AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/graphics/importer
     10AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/sound
    1011AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/gui
    1112AM_CXXFLAGS+=-I$(MAINSRCDIR)/lib/lang
     
    6970                 lib/graphics/importer/material.cc \
    7071                 lib/graphics/importer/texture.cc \
     72                 lib/sound/sound_engine.cc \
    7173                 lib/lang/base_entity.cc \
    7274                 lib/lang/base_object.cc \
     
    125127                 lib/graphics/light.h \
    126128                 lib/graphics/text_engine.h \
     129                 lib/sound/sound_engine.h \
    127130                 lib/data/data_tank.h \
    128131                 lib/lang/base_entity.h \
  • orxonox/branches/sound_engine/src/Makefile.in

    r3869 r3887  
    6868        text_engine.$(OBJEXT) array.$(OBJEXT) objModel.$(OBJEXT) \
    6969        primitive_model.$(OBJEXT) model.$(OBJEXT) material.$(OBJEXT) \
    70         texture.$(OBJEXT) base_entity.$(OBJEXT) base_object.$(OBJEXT) \
    71         ini_parser.$(OBJEXT) list.$(OBJEXT) resource_manager.$(OBJEXT) \
    72         vector.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT)
     70        texture.$(OBJEXT) sound_engine.$(OBJEXT) base_entity.$(OBJEXT) \
     71        base_object.$(OBJEXT) ini_parser.$(OBJEXT) list.$(OBJEXT) \
     72        resource_manager.$(OBJEXT) vector.$(OBJEXT) curve.$(OBJEXT) \
     73        glmenu_imagescreen.$(OBJEXT)
    7374orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    7475orxonox_LDADD = $(LDADD)
     
    102103@AMDEP_TRUE@    ./$(DEPDIR)/satellite.Po ./$(DEPDIR)/skybox.Po \
    103104@AMDEP_TRUE@    ./$(DEPDIR)/skysphere.Po \
     105@AMDEP_TRUE@    ./$(DEPDIR)/sound_engine.Po \
    104106@AMDEP_TRUE@    ./$(DEPDIR)/story_entity.Po ./$(DEPDIR)/terrain.Po \
    105107@AMDEP_TRUE@    ./$(DEPDIR)/test_bullet.Po ./$(DEPDIR)/test_gun.Po \
     
    237239target_vendor = @target_vendor@
    238240MAINSRCDIR = .
    239 AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/gui -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai -I$(MAINSRCDIR)/util -I$(MAINSRCDIR)/util/animation -I$(MAINSRCDIR)/util/common
     241AM_CXXFLAGS = -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/graphics -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/sound -I$(MAINSRCDIR)/lib/gui -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai -I$(MAINSRCDIR)/util -I$(MAINSRCDIR)/util/animation -I$(MAINSRCDIR)/util/common
    240242AM_LDFLAGS = $(MWINDOWS)
    241243orxonox_SOURCES = orxonox.cc \
     
    279281                 lib/graphics/importer/material.cc \
    280282                 lib/graphics/importer/texture.cc \
     283                 lib/sound/sound_engine.cc \
    281284                 lib/lang/base_entity.cc \
    282285                 lib/lang/base_object.cc \
     
    335338                 lib/graphics/light.h \
    336339                 lib/graphics/text_engine.h \
     340                 lib/sound/sound_engine.h \
    337341                 lib/data/data_tank.h \
    338342                 lib/lang/base_entity.h \
     
    461465@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/skybox.Po@am__quote@
    462466@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/skysphere.Po@am__quote@
     467@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound_engine.Po@am__quote@
    463468@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/story_entity.Po@am__quote@
    464469@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/terrain.Po@am__quote@
     
    10171022@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    10181023@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o texture.obj `if test -f 'lib/graphics/importer/texture.cc'; then $(CYGPATH_W) 'lib/graphics/importer/texture.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/importer/texture.cc'; fi`
     1024
     1025sound_engine.o: lib/sound/sound_engine.cc
     1026@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sound_engine.o -MD -MP -MF "$(DEPDIR)/sound_engine.Tpo" -c -o sound_engine.o `test -f 'lib/sound/sound_engine.cc' || echo '$(srcdir)/'`lib/sound/sound_engine.cc; \
     1027@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/sound_engine.Tpo" "$(DEPDIR)/sound_engine.Po"; else rm -f "$(DEPDIR)/sound_engine.Tpo"; exit 1; fi
     1028@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/sound/sound_engine.cc' object='sound_engine.o' libtool=no @AMDEPBACKSLASH@
     1029@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/sound_engine.Po' tmpdepfile='$(DEPDIR)/sound_engine.TPo' @AMDEPBACKSLASH@
     1030@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1031@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sound_engine.o `test -f 'lib/sound/sound_engine.cc' || echo '$(srcdir)/'`lib/sound/sound_engine.cc
     1032
     1033sound_engine.obj: lib/sound/sound_engine.cc
     1034@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sound_engine.obj -MD -MP -MF "$(DEPDIR)/sound_engine.Tpo" -c -o sound_engine.obj `if test -f 'lib/sound/sound_engine.cc'; then $(CYGPATH_W) 'lib/sound/sound_engine.cc'; else $(CYGPATH_W) '$(srcdir)/lib/sound/sound_engine.cc'; fi`; \
     1035@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/sound_engine.Tpo" "$(DEPDIR)/sound_engine.Po"; else rm -f "$(DEPDIR)/sound_engine.Tpo"; exit 1; fi
     1036@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/sound/sound_engine.cc' object='sound_engine.obj' libtool=no @AMDEPBACKSLASH@
     1037@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/sound_engine.Po' tmpdepfile='$(DEPDIR)/sound_engine.TPo' @AMDEPBACKSLASH@
     1038@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1039@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sound_engine.obj `if test -f 'lib/sound/sound_engine.cc'; then $(CYGPATH_W) 'lib/sound/sound_engine.cc'; else $(CYGPATH_W) '$(srcdir)/lib/sound/sound_engine.cc'; fi`
    10191040
    10201041base_entity.o: lib/lang/base_entity.cc
     
    12681289
    12691290distdir: $(DISTFILES)
    1270         $(mkdir_p) $(distdir)/ai $(distdir)/defs $(distdir)/glmenu $(distdir)/lib/coord $(distdir)/lib/data $(distdir)/lib/graphics $(distdir)/lib/lang $(distdir)/lib/math $(distdir)/lib/util $(distdir)/network $(distdir)/proto $(distdir)/story_entities $(distdir)/util $(distdir)/util/animation $(distdir)/util/common $(distdir)/world_entities
     1291        $(mkdir_p) $(distdir)/ai $(distdir)/defs $(distdir)/glmenu $(distdir)/lib/coord $(distdir)/lib/data $(distdir)/lib/graphics $(distdir)/lib/lang $(distdir)/lib/math $(distdir)/lib/sound $(distdir)/lib/util $(distdir)/network $(distdir)/proto $(distdir)/story_entities $(distdir)/util $(distdir)/util/animation $(distdir)/util/common $(distdir)/world_entities
    12711292        @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
    12721293        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
  • orxonox/branches/sound_engine/src/defs/debug.h

    r3875 r3887  
    7272#define DEBUG_MODULE_FONT               1
    7373#define DEBUG_MODULE_ANIM               1
     74#define DEBUG_MODULE_SOUND              4
    7475
    7576#define DEBUG_MODULE_NULL_PARENT        0
  • orxonox/branches/sound_engine/src/lib/sound/sound_engine.cc

    r3884 r3887  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
     14   
     15   Some code was taken from Simon's first implementation of the SoundEngine.
    1416*/
    1517
    16 //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
    1719
    18 #include "proto_singleton.h"
     20#include "sound_engine.h"
    1921
    2022using namespace std;
    21 
    2223
    2324/**
    2425   \brief standard constructor
    2526*/
    26 ProtoSingleton::ProtoSingleton ()
     27SoundEngine::SoundEngine ()
    2728{
    28    this->setClassName ("ProtoSingleton");
    29 
     29   this->setClassName ("SoundEngine");
     30   this->isInit = false;
     31   this->enableSound();
    3032}
    3133
    32 /**
    33    \brief the singleton reference to this class
    34 */
    35 ProtoSingleton* ProtoSingleton::singletonRef = NULL;
     34//! brief the singleton reference to this class
     35SoundEngine* SoundEngine::singletonRef = NULL;
    3636
    3737/**
    3838   \returns a Pointer to this Class
    3939*/
    40 ProtoSingleton* ProtoSingleton::getInstance(void)
     40SoundEngine* SoundEngine::getInstance(void)
    4141{
    42   if (!ProtoSingleton::singletonRef)
    43     ProtoSingleton::singletonRef = new ProtoSingleton();
    44   return ProtoSingleton::singletonRef;
     42  if (!SoundEngine::singletonRef)
     43    SoundEngine::singletonRef = new SoundEngine();
     44  return SoundEngine::singletonRef;
    4545}
    4646
     
    4949
    5050*/
    51 ProtoSingleton::~ProtoSingleton ()
     51SoundEngine::~SoundEngine ()
    5252{
    53   ProtoSingleton::singletonRef = NULL;
     53  SoundEngine::singletonRef = NULL;
     54 
     55  this->disableSound();
     56}
    5457
     58
     59/**
     60   \brief enables the SDL_mixer library
     61*/
     62void SoundEngine::enableSound(void)
     63{
     64  if (!this->isInit)
     65    if (SDL_Init(SDL_INIT_AUDIO))
     66      {
     67        PRINTF(1)("SDL-sound could not be initialized\n");
     68        return;
     69      }
     70  this->isInit = true;
    5571}
     72
     73/**
     74   \brief disabled SDL_mixer
     75*/
     76void SoundEngine::disableSound(void)
     77{
     78  if (this->isInit)
     79    {
     80      SDL_QuitSubSystem(SDL_INIT_AUDIO);
     81    }
     82  else
     83    PRINTF(4)("SDL_mixer was not initialized.\n");
     84}
     85
     86/**
     87   \brief checks if the compiled version and the local version of SDL_mixer match.
     88   \returns true if match, false otherwise
     89*/
     90bool SoundEngine::checkVersion(void)
     91{
     92  SDL_version compile_version;
     93  SDL_version link_version;
     94  MIX_VERSION(&compile_version);
     95  link_version = *Mix_Linked_Version();
     96
     97  if (compile_version.major == link_version.major &&
     98      compile_version.minor == link_version.minor &&
     99      compile_version.patch == link_version.patch)
     100    {
     101      return true;
     102    }
     103  else
     104    {
     105      PRINTF(2)("compiled with SDL_mixer version: %d.%d.%d\n",
     106                compile_version.major,
     107                compile_version.minor,
     108                compile_version.patch);
     109     
     110      PRINTF(2)("running with SDL_mixer version: %d.%d.%d\n",
     111                link_version.major,
     112                link_version.minor,
     113                link_version.patch);
     114      return false;
     115    }
     116}
  • orxonox/branches/sound_engine/src/lib/sound/sound_engine.h

    r3884 r3887  
    11/*!
    2     \file proto_singleton.h
    3     \brief Definition of the proto class template, used quickly start work
    4    
    5     a simple file to copy and create a singleton-class from
     2    \file sound_engine.h
     3    \brief Definition of the SoundEngine
     4
     5    !!AVOID!!:
     6    SDL_OpenAudio
     7     Use Mix_OpenAudio instead.
     8    SDL_CloseAudio
     9     Use Mix_CloseAudio instead.
     10    SDL_PauseAudio
     11     Use Mix_Pause(-1) and Mix_PauseMusic instead, to pause.
     12     Use Mix_Resume(-1) and Mix_ResumeMusic instead, to unpause.
     13    SDL_LockAudio
     14     This is just not needed since SDL_mixer handles this for you.
     15     Using it may cause problems as well.
     16    SDL_UnlockAudio
     17     This is just not needed since SDL_mixer handles this for you.
     18     Using it may cause problems as well.
    619*/
    720
    8 #ifndef _PROTO_SINGLETON_H
    9 #define _PROTO_SINGLETON_H
     21#ifndef _SOUND_ENGINE_H
     22#define _SOUND_ENGINE_H
    1023
    1124#include "base_object.h"
     25#include <SDL_mixer.h>
    1226
    13 // FORWARD DEFINITION \\
     27// FORWARD DEFINITION
    1428
    15 //! A default singleton class.
    16 class ProtoSingleton : public BaseObject {
     29//! The Main Sound Engine
     30class SoundEngine : public BaseObject {
    1731
    1832 public:
    19   static ProtoSingleton* getInstance(void);
    20   virtual ~ProtoSingleton(void);
     33  static SoundEngine* getInstance(void);
     34  virtual ~SoundEngine(void);
    2135
    2236 private:
    23   ProtoSingleton(void);
    24   static ProtoSingleton* singletonRef;
     37  SoundEngine(void);
     38  static SoundEngine* singletonRef;
     39
     40 
     41 
     42  void enableSound(void);
     43  void disableSound(void);
     44  static bool checkVersion(void);
     45
     46  bool isInit;
    2547};
    2648
    27 #endif /* _PROTO_SINGLETON_H */
     49
     50#endif /* _SOUND_ENGINE_H */
  • orxonox/branches/sound_engine/src/orxonox.cc

    r3790 r3887  
    3232#include "game_loader.h"
    3333#include "graphics_engine.h"
     34#include "sound_engine.h"
    3435#include "resource_manager.h"
    3536#include "text_engine.h"
     
    5758  if( localinput != NULL) delete world;
    5859  if( resources != NULL) delete resources;
    59   delete GraphicsEngine::getInstance(); // deleting the Graphics
     60  delete GraphicsEngine::getInstance(); // delets the Graphics Engine
     61  delete SoundEngine::getInstance();    // deletes the Sound Engine
    6062  delete ResourceManager::getInstance(); // deletes the Resource Manager
    6163  delete TextEngine::getInstance();
     
    131133{
    132134  printf("> Initializing sound\n");
    133   // SDL_Init(SDL_INIT_AUDIO);
    134   printf("Not yet implemented\n");
     135  SoundEngine::getInstance();
     136  printf("implementing\n");
    135137  return 0;
    136138}
Note: See TracChangeset for help on using the changeset viewer.