Index: /data/contentcreation/pps/FabianLandau/mover/environments/mover.cc
===================================================================
--- /data/contentcreation/pps/FabianLandau/mover/environments/mover.cc	(revision 4877)
+++ /data/contentcreation/pps/FabianLandau/mover/environments/mover.cc	(revision 4878)
@@ -15,4 +15,5 @@
 
 #include "sound/resource_sound_buffer.h"
+#include "sound_engine.h"
 #include "util/loading/load_param_xml.h"
 #include "util/loading/load_param.h"
@@ -236,5 +237,5 @@
     if (this->triggers && this->triggers->isTriggered())
     {
-        this->soundSource_moving.play();
+        this->soundSource_moving.play(this->stations->getMovingSound(this->station), OrxSound::SoundEngine::getInstance()->getEffectsVolume(), 0.5, true);
         return MOVE;
     }
@@ -278,7 +279,7 @@
 
     if (this->stations->getStartingSound(this->station).loaded())
-        this->soundSource_starting.play(this->stations->getStartingSound(this->station));
+        this->soundSource_starting.play(this->stations->getStartingSound(this->station), OrxSound::SoundEngine::getInstance()->getEffectsVolume(), 0.5);
     if (this->stations->getMovingSound(this->station).loaded())
-        this->soundSource_moving.play(this->stations->getMovingSound(this->station), 1.0, true);
+        this->soundSource_moving.play(this->stations->getMovingSound(this->station), OrxSound::SoundEngine::getInstance()->getEffectsVolume(), 0.5, true);
 
     this->time = 0;
@@ -315,5 +316,5 @@
 
         if (this->stations->getEndingSound(this->station).loaded())
-            this->soundSource_ending.play(this->stations->getEndingSound(this->station));
+            this->soundSource_ending.play(this->stations->getEndingSound(this->station), OrxSound::SoundEngine::getInstance()->getEffectsVolume(), 0.5);
         this->soundSource_moving.stop();
 
Index: /data/contentcreation/pps/FabianLandau/mover/sound/sound_engine.cc
===================================================================
--- /data/contentcreation/pps/FabianLandau/mover/sound/sound_engine.cc	(revision 4878)
+++ /data/contentcreation/pps/FabianLandau/mover/sound/sound_engine.cc	(revision 4878)
@@ -0,0 +1,417 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+
+   code has been taken from http://www.devmaster.net/articles.php?catID=6
+   The code has been applied to our needs, and many things have been changed.
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
+
+#include "sound_engine.h"
+
+#include "p_node.h"
+#include "debug.h"
+#include "parser/preferences/preferences.h"
+#include "orxonox_globals.h"
+#include "resource_sound_buffer.h"
+
+namespace OrxSound
+{
+  ObjectListDefinition(SoundEngine);
+  //////////////////
+  /* SOUND-ENGINE */
+  //////////////////
+  /**
+   * @brief standard constructor
+  */
+  SoundEngine::SoundEngine ()
+  {
+    this->registerObject(this, SoundEngine::_objectList);
+    this->setName("SoundEngine");
+
+    this->listener = NULL;
+
+    this->device = NULL;
+    this->context = NULL;
+
+    this->maxSourceCount = 32;
+
+    this->effectsVolume = .80;
+    this->musicVolume = .75;
+
+    this->sourceMutex = SDL_CreateMutex();
+  }
+
+  /**
+   * @brief the singleton reference to this class
+  */
+  SoundEngine* SoundEngine::singletonRef = NULL;
+
+  /**
+   * @brief standard destructor
+   */
+  SoundEngine::~SoundEngine ()
+  {
+    // deleting all the SoundSources
+    while (!SoundSource::objectList().empty())
+      delete (SoundSource::objectList().front());
+
+    while(!this->ALSources.empty())
+    {
+      if (alIsSource(this->ALSources.top()))
+      {
+        alDeleteSources(1, &this->ALSources.top());
+        SoundEngine::checkError("Deleting Source", __LINE__);
+      }
+      else
+        PRINTF(1)("%d is not a Source\n", this->ALSources.top());
+
+      this->ALSources.pop();
+    }
+
+    // deleting all the SoundBuffers
+    //    while(!SoundBuffer::objectList().empty())
+    //ResourceManager::getInstance()->unload(SoundBuffer::objectList().front());
+
+    // removing openAL from AudioResource
+    //! @todo this should be terminated through alc
+    //alutExit();
+
+    SDL_DestroyMutex(this->sourceMutex);
+
+    SoundEngine::singletonRef = NULL;
+  }
+
+  /**
+   * @brief loads the settings of the SoundEngine from an ini-file
+   */
+  void SoundEngine::loadSettings()
+  {
+    MultiType channels = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_AUDIO_CHANNELS, "32");
+    this->maxSourceCount = channels.getInt();
+
+    MultiType effectsVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_EFFECTS_VOLUME, "80");
+    this->effectsVolume = effectsVolume.getFloat()/100.0;
+
+    MultiType musicVolume = Preferences::getInstance()->getString(CONFIG_SECTION_AUDIO, CONFIG_NAME_MUSIC_VOLUME, "75");
+    this->musicVolume = musicVolume.getFloat()/100.0;
+  }
+
+  /**
+   * @brief creates a new SoundSource.
+   * @param fileName The Name to load the SoundBuffer from
+   * @param sourceNode The sourceNode to bind this SoundSource to.
+   * @returns The newly created SoundSource
+   *
+   * acctualy this is nothing more than a wrapper around the ResourceManager.
+  */
+  SoundSource* SoundEngine::createSource(const std::string& fileName, PNode* sourceNode)
+  {
+    SoundBuffer buffer;
+    if (!fileName.empty())
+    {
+      buffer = ResourceSoundBuffer(fileName);
+      if (!buffer.loaded())
+        PRINTF(2)("Wav-Sound %s could not be loaded onto new Source\n", fileName.c_str());
+    }
+    return new SoundSource(sourceNode, buffer);
+  }
+
+  /**
+   * @brief Sets the doppler values of openAL
+   * @param dopplerFactor the extent of the doppler-effect
+   * @param dopplerVelocity the Speed the sound travels
+  */
+  void SoundEngine::setDopplerValues(ALfloat dopplerFactor, ALfloat dopplerVelocity)
+  {
+    alDopplerFactor(dopplerFactor);
+    this->checkError("Setting Doppler Factor", __LINE__);
+
+    alDopplerVelocity(dopplerVelocity);
+    this->checkError("Setting Doppler Velocity", __LINE__);
+  }
+
+
+  /**
+   * @brief retrieves an OpenAL Source from the availiable Sources.
+   * @param source the Source to fill with the Value.
+   */
+  void SoundEngine::popALSource(ALuint& source)
+  {
+    assert (source == 0);
+    /// @TODO try to create more sources if needed
+    if (!this->ALSources.empty())
+    {
+      SDL_mutexP(this->sourceMutex);
+      source = this->ALSources.top();
+      this->ALSources.pop();
+      SDL_mutexV(this->sourceMutex);
+    }
+  }
+
+
+  /**
+   * @brief Pushes an OpenAL Source back into the Stack of known sources
+   * @param source the Source to push onto the top of the SourceStack
+   */
+  void SoundEngine::pushALSource(ALuint& source)
+  {
+    if (source != 0)
+    {
+      SDL_mutexP(this->sourceMutex);
+      this->ALSources.push(source);
+      SDL_mutexV(this->sourceMutex);
+    }
+  };
+
+
+  /**
+   * @brief updates all The positions, Directions and Velocities of all Sounds
+   */
+  void SoundEngine::update()
+  {
+    // updating the Listeners Position
+    if (likely(this->listener != NULL))
+    {
+      alListener3f(AL_POSITION,
+                   this->listener->getAbsCoor().x,
+                   this->listener->getAbsCoor().y,
+                   this->listener->getAbsCoor().z);
+      alListener3f(AL_VELOCITY,
+                   this->listener->getVelocity().x,
+                   this->listener->getVelocity().y,
+                   this->listener->getVelocity().z);
+      Vector absDirV = this->listener->getAbsDirV();
+      ALfloat orientation [6] = {1,0,0, absDirV.x, absDirV.y, absDirV.z};
+      alListenerfv(AL_ORIENTATION, orientation);
+      SoundEngine::checkError("SoundEngine::update() - Listener Error", __LINE__);
+    }
+    else
+      PRINTF(2)("no listener defined\n");
+
+    // updating all the Sources positions
+    ObjectList<SoundSource>::const_iterator sourceIT;
+    for (sourceIT = SoundSource::objectList().begin();
+         sourceIT != SoundSource::objectList().end();
+         sourceIT++)
+    {
+      if ((*sourceIT)->isPlaying())
+      {
+        int play = 0x000;
+        alGetSourcei((*sourceIT)->getID(), AL_SOURCE_STATE, &play);
+        if (DEBUG_LEVEL > 2)
+          SoundEngine::checkError("SoundEngine::update() Play", __LINE__);
+        if(play == AL_PLAYING)
+        {
+          if (likely((*sourceIT)->getNode() != NULL))
+          {
+            alSource3f((*sourceIT)->getID(), AL_POSITION,
+                       (*sourceIT)->getNode()->getAbsCoor().x,
+                       (*sourceIT)->getNode()->getAbsCoor().y,
+                       (*sourceIT)->getNode()->getAbsCoor().z);
+            if (DEBUG_LEVEL > 2)
+              SoundEngine::checkError("SoundEngine::update() Set Source Position", __LINE__);
+            alSource3f((*sourceIT)->getID(), AL_VELOCITY,
+                       (*sourceIT)->getNode()->getVelocity().x,
+                       (*sourceIT)->getNode()->getVelocity().y,
+                       (*sourceIT)->getNode()->getVelocity().z);
+            if (DEBUG_LEVEL > 2)
+              SoundEngine::checkError("SoundEngine::update() Set Source Velocity", __LINE__);
+          }
+        }
+        else
+        {
+          (*sourceIT)->stop();
+        }
+      }
+    }
+    SoundEngine::checkError("SoundEngine::update()", __LINE__);
+  }
+
+
+  /**
+   *  initializes Audio in general
+  */
+  bool SoundEngine::initAudio()
+  {
+    //   ALenum result;
+    //   PRINTF(3)("Initialisazing openAL sound engine\n");
+    //   const char* defaultDevice =(const char*) alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
+    //   const char* deviceList = (const char*)alcGetString(NULL,ALC_DEVICE_SPECIFIER);
+    //   const char* devWalk = deviceList;
+    //   //  if (alcIsExtensionPresent(NULL, (const ALCchar*)"ALC_ENUMERATION_EXT") == AL_TRUE)
+    //   { // try out enumeration extension
+    //     PRINTF(3)("Enumeration-extension found\n");
+    //
+    //     PRINTF(3)("Default device: %s\n", defaultDevice);
+    //     do
+    //     {
+    //       PRINTF(3)("%s\n", devWalk);
+    //       devWalk += strlen(devWalk)+1;
+    //     }
+    //     while (devWalk[0] != '\0');
+    //  }
+
+    // INITIALIZING THE DEVICE:
+    //   char deviceName[] =
+    //   #ifdef __WIN32__
+    //     "Direct3D";
+    //   #else
+    //     "'( ( devices '( native null ) ) )";
+    //   #endif
+
+    this->device = alcOpenDevice(NULL);
+    this->checkALCError("opening Device", __LINE__);
+
+    PRINTF(4)("Audio-Specifier: %s\n", (const char*)alcGetString(this->device, ALC_DEVICE_SPECIFIER));
+    PRINTF(4)("Audio-Extensions: %s\n", (const char*)alcGetString(this->device, ALC_EXTENSIONS));
+
+
+    this->context = alcCreateContext(this->device, NULL);
+    this->checkALCError("creating Context", __LINE__);
+
+    alcMakeContextCurrent(this->context);
+    this->checkALCError("making Context Current", __LINE__);
+    // #endif
+
+    this->setDopplerValues(SOUND_DOPPLER_FACTOR, SOUND_DOPPLER_VELOCITY);
+    this->allocateSources(this->maxSourceCount);
+    this->checkError("Allocating Sources", __LINE__);
+
+    return true;
+  }
+
+
+  /**
+   * Allocates openAL sources
+   * @param count how many sources to allocate
+   * @returns true on success, false if at least one source could not be allocated
+   */
+  bool SoundEngine::allocateSources(unsigned int count)
+  {
+    unsigned int failCount = 0;
+    for (unsigned int i = 0; i < count; i++)
+    {
+      ALuint source = 0;
+
+      alGenSources(1, &source);
+      this->checkError("allocate Source", __LINE__);
+      if (!alIsSource(source))
+      {
+        PRINTF(5)("not allocated Source\n");
+        failCount++;
+        continue;
+      }
+
+      alSourcef (source, AL_PITCH,    1.0      );
+      alSourcef (source, AL_GAIN,     this->getEffectsVolume() );
+      alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
+      alSourcei (source, AL_LOOPING,  AL_FALSE );
+      this->ALSources.push(source);
+    }
+    if (failCount == 0)
+      return true;
+    else
+    {
+      PRINTF(2)("Failed to allocate %d of %d SoundSources\n", failCount, count);
+      return false;
+    }
+  }
+
+  /**
+   * @brief checks for an OpenAL error
+   * @param error the ErrorMessage to display
+   * @param line on what line did the error occure.
+   */
+  bool SoundEngine::checkError(const std::string& error, unsigned int line)
+  {
+    ALenum errorCode;
+    if ((errorCode = alGetError()) != AL_NO_ERROR)
+    {
+      //PRINTF(1)("Error %s (line:%d): '%s'\n", error.c_str(), line, SoundEngine::getALErrorString(errorCode));
+      return false;
+    }
+    else
+      return true;
+  }
+
+  /**
+   * @brief check for an ALC error.
+   * @brief error the Error-String to display
+   * @param line on that line, the error occured (debugging mode).
+   */
+  bool SoundEngine::checkALCError(const std::string& error, unsigned int line)
+  {
+    ALenum errorCode;
+    if ((errorCode = alcGetError(this->device)) != ALC_NO_ERROR)
+    {
+      PRINTF(1)("Error %s (line:%d): '%s'\n", error.c_str(), line, SoundEngine::getALCErrorString(errorCode));
+      return false;
+    }
+    else
+      return true;
+  }
+
+
+
+  void SoundEngine::listDevices()
+  {
+    printf("%s\n",(const char*)alcGetString(NULL, ALC_DEVICE_SPECIFIER));
+  }
+
+  /**
+   *  Transforms AL-errors into something readable
+   * @param err The error found
+  */
+  const char* SoundEngine::getALErrorString(ALenum err)
+  {
+    switch(err)
+    {
+      default:
+      case AL_NO_ERROR:
+      return ("AL_NO_ERROR");
+      case AL_INVALID_NAME:
+      return ("AL_INVALID_NAME");
+      case AL_INVALID_ENUM:
+      return ("AL_INVALID_ENUM");
+      case AL_INVALID_VALUE:
+      return ("AL_INVALID_VALUE");
+      case AL_INVALID_OPERATION:
+      return ("AL_INVALID_OPERATION");
+      case AL_OUT_OF_MEMORY:
+      return ("AL_OUT_OF_MEMORY");
+    };
+  }
+
+
+  const char* SoundEngine::getALCErrorString(ALenum err)
+  {
+    switch(err)
+    {
+      default:
+      case ALC_NO_ERROR:
+      return ("AL_NO_ERROR");
+      case ALC_INVALID_DEVICE:
+      return ("ALC_INVALID_DEVICE");
+      case ALC_INVALID_CONTEXT:
+      return("ALC_INVALID_CONTEXT");
+      case ALC_INVALID_ENUM:
+      return("ALC_INVALID_ENUM");
+      case ALC_INVALID_VALUE:
+      return ("ALC_INVALID_VALUE");
+      case ALC_OUT_OF_MEMORY:
+      return("ALC_OUT_OF_MEMORY");
+    };
+  }
+}
Index: /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.cc
===================================================================
--- /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.cc	(revision 4878)
+++ /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.cc	(revision 4878)
@@ -0,0 +1,408 @@
+/*
+  orxonox - the future of 3D-vertical-scrollers
+
+  Copyright (C) 2004 orx
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2, or (at your option)
+  any later version.
+
+  ### File Specific:
+  main-programmer: Benjamin Grauer
+  co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
+
+#include "sound_source.h"
+#include "sound_engine.h"
+
+#include "compiler.h"
+#include "debug.h"
+
+namespace OrxSound
+{
+  ObjectListDefinition(SoundSource);
+  /**
+  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
+  */
+  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer& buffer)
+  {
+    this->registerObject(this, SoundSource::_objectList);
+    // adding the Source to the SourcesList of the SoundEngine
+    this->buffer = buffer;
+    this->sourceNode = sourceNode;
+    this->resident = false;
+
+    this->sourceID = 0;
+    this->bPlay = false;
+  }
+
+
+  /**
+  * @brief construct a SoundSource out of the another soundSource
+  * @param source the Source to create this source from.
+  *
+  * Copies the buffer from source to this Source.
+  * Acquires a new SourceID if source is Playing.
+  */
+  SoundSource::SoundSource(const SoundSource& source)
+  {
+    this->registerObject(this, SoundSource::_objectList);
+
+    // adding the Source to the SourcesList of the SoundEngine
+    this->buffer = source.buffer;
+    this->sourceNode = source.sourceNode;
+    this->resident = source.resident;
+
+    this->sourceID = 0;
+    if (source.bPlay == true)
+    {
+      this->bPlay = true;
+      SoundEngine::getInstance()->popALSource(this->sourceID);
+    }
+    else
+      this->bPlay = false;
+  }
+
+
+  /**
+  * @brief paste a copy of the source into this Source.
+  * @param source the SoundSource to paste into this one.
+  * @returns a Reference to this Source.
+  *
+  */
+  SoundSource& SoundSource::operator=(const SoundSource& source)
+  {
+    this->buffer = source.buffer;
+    this->sourceNode = sourceNode;
+    this->resident = source.resident;
+
+    if (source.bPlay)
+      this->play();
+    else
+      this->stop();
+
+    return *this;
+  }
+
+
+  /**
+  * @brief compares two Sources with each other.
+  * @param source the Source to compare against this One.
+  * Two Sources are the same, if the PNodes match, and the Sound Played are the same.
+  * The alSource must not match, because no two Sources can have the same alSource.
+  */
+  bool SoundSource::operator==(const SoundSource& source)
+  {
+    return (this->buffer == source.buffer &&
+            this->bPlay == source.bPlay &&
+            this->sourceNode == source.sourceNode);
+  }
+
+
+  /**
+  * @brief deletes a SoundSource
+  */
+  SoundSource::~SoundSource()
+  {
+    this->stop();
+    if (this->sourceID != 0)
+      SoundEngine::getInstance()->pushALSource(this->sourceID);
+  }
+
+
+  /**
+  * @brief Plays back a SoundSource
+  */
+  void SoundSource::play()
+  {
+    if (this->retrieveSource())
+    {
+      if (this->bPlay)
+        alSourceStop(this->sourceID);
+
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
+      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+//      alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
+      alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
+      alSourcePlay(this->sourceID);
+
+      if (DEBUG_LEVEL >= 3)
+        SoundEngine::checkError("Play Source", __LINE__);
+      this->bPlay = true;
+    }
+  }
+
+
+  /**
+  * @brief Plays back buffer on this Source
+  * @param buffer the buffer to play back on this Source
+  */
+  void SoundSource::play(const SoundBuffer& buffer)
+  {
+    if (!this->retrieveSource())
+    {
+      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+      return;
+    }
+
+    alSourceStop(this->sourceID);
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
+    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+//    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, 0.0);
+    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
+
+    alSourcePlay(this->sourceID);
+
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
+    this->bPlay = true;
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Play Source", __LINE__);
+  }
+
+
+  /**
+   * @brief Plays back buffer on this Source with gain
+   * @param buffer the buffer to play back on this Source
+   * @param gain the gain of the sound buffer
+   * @param rolloff the rolloff of the sound buffer
+  */
+  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff)
+  {
+    if (!this->retrieveSource())
+    {
+      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+      return;
+    }
+
+    alSourceStop(this->sourceID);
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
+    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
+    alSourcef (this->sourceID, AL_GAIN, gain);
+
+    alSourcePlay(this->sourceID);
+
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
+    this->bPlay = true;
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Play Source", __LINE__);
+  }
+
+  /**
+   * @brief Plays back buffer on this Source with gain, rolloff and looping possibility
+   * @param buffer the buffer to play back on this Source
+   * @param gain the gain of the sound buffer
+   * @param rolloff the rolloff of the sound buffer
+   * @param loop if true, sound gets looped
+   */
+  void SoundSource::play(const SoundBuffer& buffer, float gain, float rolloff, bool loop)
+  {
+    if (!this->retrieveSource())
+    {
+      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+      return;
+    }
+
+    alSourceStop(this->sourceID);
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
+
+    if (loop)
+      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
+    else
+      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+
+    alSourcef (this->sourceID, AL_GAIN, gain);
+    alSourcef (this->sourceID, AL_ROLLOFF_FACTOR, rolloff);
+
+    alSourcePlay(this->sourceID);
+
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
+    this->bPlay = true;
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Play Source", __LINE__);
+  }
+
+  /**
+   * @brief Plays back buffer on this Source with looping possibility
+   * @param buffer the buffer to play back on this Source
+   * @param loop if true, sound gets looped
+   */
+  void SoundSource::play(const SoundBuffer& buffer, bool loop)
+  {
+    if (!this->retrieveSource())
+    {
+      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
+      return;
+    }
+
+    alSourceStop(this->sourceID);
+    alSourcei (this->sourceID, AL_BUFFER, buffer.getID());
+
+    if (loop)
+      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
+    else
+      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
+
+    alSourcef (this->sourceID, AL_GAIN, SoundEngine::getInstance()->getEffectsVolume());
+
+    alSourcePlay(this->sourceID);
+
+    if (unlikely(this->buffer.getID() != 0))
+      alSourcei (this->sourceID, AL_BUFFER, this->buffer.getID());
+    this->bPlay = true;
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Play Source", __LINE__);
+  }
+  
+  /**
+   * @brief Changes the volume of an (active) buffer
+   * @param buffer the buffer to play back on this Source
+   * @param gain the new gain value
+   */
+  void SoundSource::gain(const SoundBuffer& buffer, float gain)
+  {
+    // alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
+    alSourcef (this->sourceID, AL_GAIN, gain);
+  }
+
+  /**
+   * @brief Stops playback of a SoundSource
+   */
+  void SoundSource::stop()
+  {
+    this->bPlay = false;
+    if (this->sourceID != 0)
+    {
+      this->bPlay = false;
+      if (this->sourceID != 0)
+      {
+        alSourceStop(this->sourceID);
+        if (DEBUG_LEVEL >= 3)
+          SoundEngine::checkError("StopSource", __LINE__);
+        alSourcei(this->sourceID, AL_BUFFER, 0);
+        if (!this->resident)
+          SoundEngine::getInstance()->pushALSource(this->sourceID);
+        this->sourceID = 0;
+      }
+    }
+  }
+
+  /**
+  * @brief Pauses Playback of a SoundSource
+  */
+  void SoundSource::pause()
+  {
+    alSourcePause(this->sourceID);
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Pause Source", __LINE__);
+  }
+
+
+  /**
+  * @brief Rewinds Playback of a SoundSource
+  */
+  void SoundSource::rewind()
+  {
+    alSourceRewind(this->sourceID);
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Rewind Source", __LINE__);
+  }
+
+
+  /**
+  * @brief sets the RolloffFactor of the Sound emitted from the SoundSource
+  * @param rolloffFactor The Factor described
+  *
+  * this tells openAL how fast the Sounds decay outward from the Source
+  */
+  void SoundSource::setRolloffFactor(ALfloat rolloffFactor)
+  {
+    alSourcef(this->sourceID, AL_ROLLOFF_FACTOR, rolloffFactor);
+
+    if (DEBUG_LEVEL >= 3)
+      SoundEngine::checkError("Set Source Rolloff-factor", __LINE__);
+  }
+
+
+  /**
+  * @brief sets the Positional this Source should be attached to.
+  * @param sourceNode the Source this is attached to.
+  * If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels.
+  */
+  void SoundSource::setSourceNode(const PNode* sourceNode)
+  {
+    this->sourceNode = sourceNode;
+  }
+
+  /**
+  * @brief retrieve a Source.
+  */
+  bool SoundSource::retrieveSource()
+  {
+    if (this->sourceID != 0)
+      return true;
+    else
+    {
+      SoundEngine::getInstance()->popALSource(this->sourceID);
+      if (this->sourceID != 0)
+      {
+        if (unlikely(this->sourceNode == NULL))
+          resetSource(this->sourceID);
+        return true;
+      }
+    }
+    return false;
+  }
+
+
+  /**
+  * @brief reset an alSource to its default Values.
+  */
+  void SoundSource::resetSource(ALuint sourceID)
+  {
+    alSource3f(sourceID, AL_POSITION,        0.0, 0.0, 0.0);
+    alSource3f(sourceID, AL_VELOCITY,        0.0, 0.0, 0.0);
+    alSource3f(sourceID, AL_DIRECTION,       0.0, 0.0, 0.0);
+    alSourcef (sourceID, AL_ROLLOFF_FACTOR,  0.0          );
+    //alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE      );
+    alSourcef (sourceID, AL_GAIN,            SoundEngine::getInstance()->getEffectsVolume());
+  }
+
+
+  /**
+  * @brief Fades in a Source over a time period
+  * @param duration time perios to fade in
+  */
+  void SoundSource::fadein(const SoundBuffer& buffer, ALfloat duration)
+  {
+    //if (this->buffer && this->retrieveSource())
+    //{
+
+    for (ALfloat n = 0.0; n < 1.0; n+=.01)
+    {
+      alSourcef(this->sourceID, AL_GAIN, n);
+      // sleep(1);
+    }
+
+    //  alSourcePlay(this->sourceID);
+
+    //  if (DEBUG_LEVEL >= 3)
+    //    SoundEngine::checkError("Loop Source", __LINE__);
+    //  this->bPlay = true;
+    //}
+
+  }
+
+
+}
Index: /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.h
===================================================================
--- /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.h	(revision 4878)
+++ /data/contentcreation/pps/FabianLandau/mover/sound/sound_source.h	(revision 4878)
@@ -0,0 +1,73 @@
+/*!
+* @file sound_source.h
+* @brief Definition of the SoundSource.
+*/
+
+#ifndef _SOUND_SOURCE_H
+#define _SOUND_SOURCE_H
+
+#include "base_object.h"
+#include "sound_buffer.h"
+#include "alincl.h"
+
+// FORWARD DECLARATION
+class PNode;
+namespace OrxSound
+{
+  //! A class that represents a SoundSource
+  class SoundSource : public BaseObject
+  {
+    ObjectListDeclaration(SoundSource);
+  public:
+    SoundSource(const PNode* sourceNode = NULL, const SoundBuffer& buffer = SoundBuffer());
+    SoundSource(const SoundSource& source);
+    SoundSource& operator=(const SoundSource& source);
+    bool operator==(const SoundSource& source);
+
+    virtual ~SoundSource();
+
+    // user interaction
+    void play();
+    void play(const SoundBuffer& buffer);
+    void play(const SoundBuffer& buffer, float gain, float rolloff);
+    void play(const SoundBuffer& buffer, float gain, float rolloff, bool loop);
+    void play(const SoundBuffer& buffer, bool loop);
+
+    void gain(const SoundBuffer& buffer, float gain);
+
+    void stop();
+    void pause();
+    void rewind();
+    void fadein(const SoundBuffer& buffer, ALfloat duration);
+
+    // development functions
+    /** @returns The ID of this Source */
+    inline ALuint getID() const { return this->sourceID; };
+    /** @returns true, if the Source is Playing */
+    inline bool isPlaying() const { return this->bPlay; };
+    void setSourceNode(const PNode* sourceNode);
+    /** @returns the SoundBuffer of this Source */
+    inline const SoundBuffer& getBuffer() const { return this->buffer; };
+    /** @returns the SourceNode of this Source */
+    inline const PNode* getNode() const { return this->sourceNode; };
+    /** @param resident if the Source is Resident */
+    inline void setResident(bool resident) { this->resident = resident; };
+    /** @returns true if the alSource is Resident */
+    inline bool isResident() const { return this->resident; };
+
+    void setRolloffFactor(ALfloat rolloffFactor);
+
+    static void resetSource(ALuint sourceID);
+
+  private:
+    bool                   retrieveSource();
+
+  private:
+    bool                   bPlay;       //!< If the Source is Playing.
+    bool                   resident;    //!< If the alSource should be resident (if true, the alSource will be returned on deletion).
+    ALuint                 sourceID;    //!< The ID of the Source
+    SoundBuffer            buffer;      //!< The buffer to play in this source.
+    const PNode*           sourceNode;  //!< The SourceNode representing the position/velocity... of this source.
+  };
+}
+#endif /* _SOUND_SOURCE_H */
