Index: code/branches/audio/src/audio/Ambient.cc
===================================================================
--- code/branches/audio/src/audio/Ambient.cc	(revision 337)
+++ code/branches/audio/src/audio/Ambient.cc	(revision 338)
@@ -1,113 +1,21 @@
 #include <iostream>
+#include <string>
 #include "Ambient.h"
-#include "../../include/AL/al.h"
-#include "../../include/AL/alc.h"
-#include "../../include/AL/alut.h"
 
 namespace audio
 {
-	Ambient::Ambient()
+	Ambient::Ambient(std::string audioFile)
 	{
-		SourcePos[0]=0;
-		SourcePos[1]=0;
-		SourcePos[2]=0;
-
-		 SourceVel[0]=0;
-		 SourceVel[1]=0;
-		 SourceVel[2]=0;
-
-		 ListenerPos[0]=0;
-		 ListenerPos[1]=0;
-		 ListenerPos[2]=0;
-
-		 ListenerVel[0]=0;
-		 ListenerVel[1]=0;
-		 ListenerVel[2]=0;
-
-		 ListenerOri[0]=0;
-		 ListenerOri[1]=0;
-		 ListenerOri[2]=-1;
-		 ListenerOri[3]=0;
-		 ListenerOri[4]=1;
-		 ListenerOri[5]=0;
-
-
-	// Initialize OpenAL and clear the error bit.
-
-	alutInit(NULL, 0);
-	alGetError();
-
-	// Load the wav data.
-
-	if(LoadALData() == AL_FALSE)
-	{
-	    printf("Error loading sound data.");
+		a = new AudioObject(audioFile);
+	}
+	
+	Ambient::~Ambient()
+	{	
 		
 	}
-
-	SetListenerValues();
-
-	// Setup an exit procedure.
-
-	//atexit(KillALData);
-
-		std::cout << "Play sone ambient background sound";
-	}
 	
-	ALboolean Ambient::LoadALData()
-	{
-		ALenum format;
-		ALsizei size;
-		ALvoid* data;
-		ALsizei freq;
-		ALboolean loop;
-	
-	
-		alGenBuffers(1, &Buffer);
-	
-		if(alGetError() != AL_NO_ERROR)
-			return AL_FALSE;
-	
-		alutLoadWAVFile((ALbyte*)"wavdata/pirate.wav", &format, &data, &size, &freq, &loop);
-		alBufferData(Buffer, format, data, size, freq);
-		alutUnloadWAV(format, data, size, freq);
-	
-		alGenSources(1, &Source);
-	
-		if(alGetError() != AL_NO_ERROR)
-			return AL_FALSE;
-	
-		alSourcei (Source, AL_BUFFER,   Buffer   );
-		alSourcef (Source, AL_PITCH,    1.0      );
-		alSourcef (Source, AL_GAIN,     1.0      );
-		alSourcefv(Source, AL_POSITION, SourcePos);
-		alSourcefv(Source, AL_VELOCITY, SourceVel);
-		alSourcei (Source, AL_LOOPING,  loop     );
-	
-		if(alGetError() == AL_NO_ERROR)
-			return AL_TRUE;
-	
-	
-		return AL_FALSE;
-	}	
-
-	void Ambient::SetListenerValues()
-	{
-		alListenerfv(AL_POSITION,    ListenerPos);
-		alListenerfv(AL_VELOCITY,    ListenerVel);
-		alListenerfv(AL_ORIENTATION, ListenerOri);
-	}
-	
-	void Ambient::KillALData()
-	{
-		alDeleteBuffers(1, &Buffer);
-		alDeleteSources(1, &Source);
-		alutExit();
-	}
-
 	void Ambient::play()
 	{
-		alSourcePlay(Source);
-	
+		a->play();	
 	}
 }
Index: code/branches/audio/src/audio/Ambient.h
===================================================================
--- code/branches/audio/src/audio/Ambient.h	(revision 337)
+++ code/branches/audio/src/audio/Ambient.h	(revision 338)
@@ -7,4 +7,5 @@
 #include "../../include/AL/alut.h"
 
+#include "AudioObject.h"
 
 namespace audio
@@ -13,24 +14,10 @@
 	{
 	public:
-		Ambient();
+		Ambient(std::string audioFile);
+		~Ambient();
 		void play();
 	private:
-		ALboolean LoadALData();	
-		void SetListenerValues();
-		void KillALData();
-
-		ALuint Buffer;
-		ALuint Source;
-		ALfloat SourcePos[3];
-		ALfloat SourceVel[3];
-		ALfloat ListenerPos[3];
-		ALfloat ListenerVel[3];
-		ALfloat ListenerOri[6];
+		AudioObject* a;
 	};
-	
-	
-	
-	
-	
 }
 
Index: code/branches/audio/src/audio/CMakeLists.txt
===================================================================
--- code/branches/audio/src/audio/CMakeLists.txt	(revision 337)
+++ code/branches/audio/src/audio/CMakeLists.txt	(revision 338)
@@ -1,6 +1,12 @@
 PROJECT(Orxonox)
 
-SET(SRC_FILES Ambient.cc)
-SET(INC_FILES Ambient.h)
+SET(SRC_FILES 
+	Ambient.cc
+	AudioObject.cc
+)
+SET(INC_FILES 
+	Ambient.h
+	AudioObject.h
+)
 
 
Index: code/branches/audio/src/orxonox/orxonox.cc
===================================================================
--- code/branches/audio/src/orxonox/orxonox.cc	(revision 337)
+++ code/branches/audio/src/orxonox/orxonox.cc	(revision 338)
@@ -191,6 +191,6 @@
       void createScene(void)
       {
-				audio::Ambient* bgsound = new audio::Ambient();
-				bgsound->play();
+		audio::Ambient* bgsound = new audio::Ambient("wavdata/pirate.wav");
+		bgsound->play();
 				        
         string levelFile = "sp_level_moonstation.oxw";
