Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3892 in orxonox.OLD


Ignore:
Timestamp:
Apr 19, 2005, 2:54:20 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: playing music works :)
now it really is bedTime

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

Legend:

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

    r3890 r3892  
    2828  SOUND AND MUSIC
    2929  ---------------*/
    30 
     30/**
     31   \brief determines the Type of a Sound by extension
     32*/
    3133Sound::Sound(const char* fileName, SOUND_TYPE soundType)
    3234{
     
    5355}
    5456
     57/**
     58   \brief deletes a Sound
     59*/
    5560Sound::~Sound()
    5661{
     
    5863}
    5964
     65
     66/**
     67   \brief loads a SoundEffect
     68*/
    6069SoundEffect::SoundEffect(const char* fileName, SOUND_TYPE soundType) : Sound(fileName, soundType)
    6170{
     
    7584}
    7685
     86/**
     87   \brief unloads a SoundEffect
     88*/
    7789SoundEffect::~SoundEffect(void)
    7890{
     
    8193}
    8294
     95void SoundEffect::play(void)
     96{
     97  if(unlikely(Mix_PlayChannel(-1, this->effect, 0) == -1))
     98    printf("Mix_PlayChannel: %s\n", Mix_GetError());
     99}
     100
     101void SoundEffect::stop(void)
     102{
     103 
     104}
     105
     106/**
     107   \brief loads a Music
     108*/
    83109Music::Music(const char* fileName, SOUND_TYPE soundType) : Sound(fileName, soundType)
    84110{
     111  PRINTF(1)("Loading Music %s\n", fileName);
    85112  this->music = NULL;
    86113  if (likely(SoundEngine::isInit))
     
    99126}
    100127
     128/**
     129   \brief unloads a Music
     130*/
    101131Music::~Music()
    102132{
    103133  Mix_FreeMusic(this->music);
     134}
     135
     136void Music::play(void)
     137{
     138  if(unlikely(Mix_PlayMusic(music, 1) == -1))
     139    printf("Mix_PlayMusic: %s\n",Mix_GetError());
     140}
     141
     142void Music::stop(void)
     143{
     144 
    104145}
    105146
  • orxonox/branches/sound_engine/src/lib/sound/sound_engine.h

    r3890 r3892  
    4343  Sound(const char* fileName, SOUND_TYPE soundType);
    4444  virtual ~Sound(void);
     45
     46  virtual void play() = 0;
     47  virtual void stop() = 0;
     48
    4549 protected:
    4650  SOUND_TYPE soundType;
    4751  int channel;
     52  int volume;
    4853};
    4954
     
    5257  SoundEffect(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
    5358  virtual ~SoundEffect(void);
     59
     60  virtual void play();
     61  virtual void stop();
    5462 private:
    5563  Mix_Chunk* effect;
     
    6068  Music(const char* fileName, SOUND_TYPE soundType = SOUND_NONE);
    6169  virtual ~Music(void);
     70
     71  virtual void play();
     72  virtual void stop();
    6273 private:
    6374  Mix_Music* music;
  • orxonox/branches/sound_engine/src/orxonox.cc

    r3889 r3892  
    6060  if( resources != NULL) delete resources;
    6161  delete GraphicsEngine::getInstance(); // delets the Graphics Engine
    62   //  delete SoundEngine::getInstance();    // deletes the Sound Engine
     62  delete SoundEngine::getInstance();    // deletes the Sound Engine
    6363  delete ResourceManager::getInstance(); // deletes the Resource Manager
    6464  delete TextEngine::getInstance();
     
    102102  // initialize everything
    103103  if( initVideo() == -1) return -1;
     104  // init sound
    104105  if( initSound() == -1) return -1;
    105106  printf("> Initializing input\n");
     
    112113  //if( init_world () == -1) return -1; PB: world will be initialized when started
    113114 
     115  Sound* test = (Sound*)ResourceManager::getInstance()->load("sound/16.mp3", RESOURCE_SOUND_MUSIC, RP_LEVEL);
     116  test->play();
     117
    114118  return 0;
    115119}
Note: See TracChangeset for help on using the changeset viewer.