Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4197 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
May 16, 2005, 3:54:06 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/openAL: playing some sound.

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

Legend:

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

    r4196 r4197  
    1717
    1818#include "sound_engine.h"
     19
    1920#include "p_node.h"
    2021#include "list.h"
     
    2324
    2425
     26//////////////////
     27/* SOUND-BUFFER */
     28//////////////////
    2529/**
    2630   \brief Creates a Soundbuffer out of an inputfile
     
    4650}
    4751
    48 
    49 
     52//////////////////
     53/* SOUND-SOURCE */
     54//////////////////
    5055/**
    5156   \brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
     
    5762  this->buffer = buffer;
    5863  this->sourceNode = sourceNode;
     64
     65  alGenSources(1, &this->sourceID);
     66
     67  if(alGetError() != AL_NO_ERROR)
     68    PRINTF(1)("error initializing SoundSource\n"); //return AL_FALSE;
     69 
     70  alSourcei (this->sourceID, AL_BUFFER,   this->buffer->getID());
     71  alSourcef (this->sourceID, AL_PITCH,    1.0      );
     72  alSourcef (this->sourceID, AL_GAIN,     1.0      );
     73  //  alSourcefv(sourceID, AL_POSITION, SourcePos);
     74  //  alSourcefv(sourceID, AL_VELOCITY, SourceVel);
     75   alSourcei (sourceID, AL_LOOPING,  true     );
     76 
     77
    5978}
    6079
     
    6483}
    6584
     85
     86void SoundSource::play()
     87{
     88  alSourcePlay(this->sourceID);
     89}
     90void SoundSource::stop()
     91{
     92  alSourceStop(this->sourceID);
     93}
     94void SoundSource::pause()
     95{
     96  alSourcePause(this->sourceID);
     97}
     98
     99
     100//////////////////
     101/* SOUND-ENGINE */
     102//////////////////
    66103/**
    67104   \brief standard constructor
     
    155192                   absDirV.z);
    156193    }
     194  else
     195    PRINTF(2)("no listener defined\n");
     196
    157197  // updating all the Sources positions
    158198  tIterator<SoundSource>* iterator = this->sourceList->getIterator();
  • orxonox/branches/openAL/src/lib/sound/sound_engine.h

    r4196 r4197  
    2323  ~SoundBuffer(void);
    2424
     25  inline ALuint getID(void) { return this->bufferID; }
     26
    2527 private:
    2628  ALuint bufferID;              //!< The address of the Buffer.
     
    3739  ~SoundSource(void);
    3840
     41  // user interaction
     42  void play();
     43  void stop();
     44  void pause();
     45 
     46
     47  // development functions
    3948  /** \retruns The ID of the Source */
    4049  inline ALuint getID(void) { return this->sourceID; }
  • orxonox/branches/openAL/src/story_entities/world.cc

    r4194 r4197  
    5050
    5151#include "substring.h"
     52
     53#include "sound_engine.h"
    5254
    5355using namespace std;
     
    486488  terrain->setRelCoor(Vector(0,-10,0));
    487489  this->spawn(terrain);
     490
     491  SoundEngine::getInstance()->setListener(tn);
     492  SoundBuffer* tBuffer =new SoundBuffer("explo.wav");
     493  SoundSource* tSound = new SoundSource(tBuffer, this->localPlayer);
     494  tSound->play();
    488495
    489496
     
    11611168  this->garbageCollector->update();
    11621169  this->nullParent->update (this->dtS);
     1170
     1171  SoundEngine::getInstance()->update();
    11631172}
    11641173
Note: See TracChangeset for help on using the changeset viewer.