Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3889 in orxonox.OLD for orxonox/branches/sound_engine


Ignore:
Timestamp:
Apr 19, 2005, 1:21:14 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/sound_engine: sound gets enabled

Location:
orxonox/branches/sound_engine/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound_engine/src/lib/sound/sound_engine.cc

    r3887 r3889  
    1919
    2020#include "sound_engine.h"
     21#include <SDL_mixer.h>
    2122
    2223using namespace std;
     
    2829{
    2930   this->setClassName ("SoundEngine");
     31
     32   // preInit
    3033   this->isInit = false;
     34   this->frequency = SOUND_DEFAULT_FREQUENCY;
     35   this->format = MIX_DEFAULT_FORMAT;
     36   this->channels = SOUND_DEFAULT_CHANNELS;
     37   this->buffers = SOUND_DEFAULT_BUFIZE;
     38
    3139   this->enableSound();
    3240}
    3341
    34 //! brief the singleton reference to this class
     42/**
     43   \brief the singleton reference to this class
     44*/
    3545SoundEngine* SoundEngine::singletonRef = NULL;
    3646
     
    6373{
    6474  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;
     75    {
     76      if (SDL_Init(SDL_INIT_AUDIO) == -1)
     77        {
     78          PRINTF(1)("SDL-sound could not be initialized\nSDL_Init: %s\n", SDL_GetError());
     79          return;
     80        }
     81      else
     82        {
     83          this->isInit = true;
     84         
     85          // checking if the mode is supported
     86          Mix_QuerySpec(&this->frequency, &this->format, &this->channels);
     87         
     88          this->bits = this->format & 0xFF;
     89          PRINTF(3)("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n",
     90                    this->frequency, this->bits, this->channels > 1 ? "stereo" : "mono", this->buffers);
     91          Mix_VolumeMusic(this->volume);
     92         
     93          if(Mix_OpenAudio(this->frequency, this->format, this->channels, this->buffers) == -1)
     94            PRINTF(1)("Mix_OpenAudio: %s\n", Mix_GetError());
     95        }
     96 
     97
     98    }
    7199}
    72100
     
    78106  if (this->isInit)
    79107    {
    80       SDL_QuitSubSystem(SDL_INIT_AUDIO);
     108      Mix_CloseAudio();
    81109    }
    82110  else
  • orxonox/branches/sound_engine/src/lib/sound/sound_engine.h

    r3887 r3889  
    2525#include <SDL_mixer.h>
    2626
     27#define SOUND_DEFAULT_FREQUENCY 44100
     28#define SOUND_DEFAULT_CHANNELS 2
     29#define SOUND_DEFAULT_BUFIZE 16384
     30
    2731// FORWARD DEFINITION
    2832
     
    4448  static bool checkVersion(void);
    4549
     50
     51  // settings
     52  int volume;
     53
     54  // audio specifications
     55  int frequency;
     56  Uint16 format;
     57  int channels;
     58  int bits;
     59  int buffers;
     60
    4661  bool isInit;
    4762};
  • orxonox/branches/sound_engine/src/orxonox.cc

    r3887 r3889  
    3333#include "graphics_engine.h"
    3434#include "sound_engine.h"
     35#include "text_engine.h"
    3536#include "resource_manager.h"
    36 #include "text_engine.h"
     37
    3738
    3839#include <string.h>
     
    5960  if( resources != NULL) delete resources;
    6061  delete GraphicsEngine::getInstance(); // delets the Graphics Engine
    61   delete SoundEngine::getInstance();    // deletes the Sound Engine
     62  //  delete SoundEngine::getInstance();    // deletes the Sound Engine
    6263  delete ResourceManager::getInstance(); // deletes the Resource Manager
    6364  delete TextEngine::getInstance();
     
    126127}
    127128
    128 
    129129/**
    130130   \brief initializes the sound engine
     
    138138}
    139139
    140 
    141140/**
    142141   \brief initializes input functions
     
    149148  return 0;
    150149}
    151 
    152150
    153151/**
Note: See TracChangeset for help on using the changeset viewer.