Index: /orxonox/branches/sound/src/demo1.c
===================================================================
--- /orxonox/branches/sound/src/demo1.c	(revision 2777)
+++ /orxonox/branches/sound/src/demo1.c	(revision 2777)
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "SDL.h"
+#include "SDL_mixer.h"
+
+/* Mix_Music actually holds the music information.  */
+Mix_Music *music = NULL;
+
+void handleKey(SDL_KeyboardEvent key);
+void musicDone();
+
+int main(void) {
+
+  SDL_Surface *screen;
+  SDL_Event event;
+  int done = 0;
+
+  /* We're going to be requesting certain things from our audio
+     device, so we set them up beforehand */
+  int audio_rate = 22050;
+  Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
+  int audio_channels = 2;
+  int audio_buffers = 4096;
+
+  SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
+
+  /* This is where we open up our audio device.  Mix_OpenAudio takes
+     as its parameters the audio format we'd /like/ to have. */
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
+    printf("Unable to open audio!\n");
+    exit(1);
+  }
+
+  /* If we actually care about what we got, we can ask here.  In this
+     program we don't, but I'm showing the function call here anyway
+     in case we'd want to know later. */
+  Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+
+  /* We're going to be using a window onscreen to register keypresses
+     in.  We don't really care what it has in it, since we're not
+     doing graphics, so we'll just throw something up there. */
+  screen = SDL_SetVideoMode(320, 240, 0, 0);
+
+  while(!done) {
+    while(SDL_PollEvent(&event)) {
+      switch(event.type) {
+      case SDL_QUIT:
+done = 1;
+break;
+      case SDL_KEYDOWN:
+      case SDL_KEYUP:
+handleKey(event.key);
+break;
+      }
+    }
+
+    /* So we don't hog the CPU */
+    SDL_Delay(50);
+
+  }
+
+  /* This is the cleaning up part */
+  Mix_CloseAudio();
+  SDL_Quit();
+
+}
+
+void handleKey(SDL_KeyboardEvent key) {
+  switch(key.keysym.sym) {
+  case SDLK_m:
+    if(key.state == SDL_PRESSED) {
+
+      /* Here we're going to have the 'm' key toggle the music on and
+ off.  When it's on, it'll be loaded and 'music' will point to
+ something valid.  If it's off, music will be NULL. */
+
+      if(music == NULL) {
+
+/* Actually loads up the music */
+music = Mix_LoadMUS("music.ogg");
+
+/* This begins playing the music - the first argument is a
+   pointer to Mix_Music structure, and the second is how many
+   times you want it to loop (use -1 for infinite, and 0 to
+   have it just play once) */
+Mix_PlayMusic(music, 0);
+
+/* We want to know when our music has stopped playing so we
+   can free it up and set 'music' back to NULL.  SDL_Mixer
+   provides us with a callback routine we can use to do
+   exactly that */
+Mix_HookMusicFinished(musicDone);
+
+      } else {
+/* Stop the music from playing */
+Mix_HaltMusic();
+
+/* Unload the music from memory, since we don't need it
+   anymore */
+Mix_FreeMusic(music);
+
+music = NULL;
+      }
+      break;
+    }
+  }
+}
+
+/* This is the function that we told SDL_Mixer to call when the music
+   was finished. In our case, we're going to simply unload the music
+   as though the player wanted it stopped.  In other applications, a
+   different music file might be loaded and played. */
+void musicDone() {
+  Mix_HaltMusic();
+  Mix_FreeMusic(music);
+  music = NULL;
+}
Index: /orxonox/branches/sound/src/demo2.c
===================================================================
--- /orxonox/branches/sound/src/demo2.c	(revision 2777)
+++ /orxonox/branches/sound/src/demo2.c	(revision 2777)
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "SDL.h"
+#include "SDL_mixer.h"
+
+/* Mix_Chunk is like Mix_Music, only it's for ordinary sounds. */
+Mix_Chunk *phaser = NULL;
+
+/* Every sound that gets played is assigned to a channel.  Note that
+   this is different from the number of channels you request when you
+   open the audio device; a channel in SDL_mixer holds information
+   about a sound sample that is playing, while the number of channels
+   you request when opening the device is dependant on what sort of
+   sound you want (1 channel = mono, 2 = stereo, etc) */
+int phaserChannel = -1;
+
+void handleKey(SDL_KeyboardEvent key);
+
+int main(void) {
+
+  SDL_Surface *screen;
+  SDL_Event event;
+  int done = 0;
+
+  /* Same setup as before */
+  int audio_rate = 22050;
+  Uint16 audio_format = AUDIO_S16; 
+  int audio_channels = 2;
+  int audio_buffers = 4096;
+
+  SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
+
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
+    printf("Unable to open audio!\n");
+    exit(1);
+  }
+
+  /* We're going to pre-load the sound effects that we need right here
+   */
+  phaser = Mix_LoadWAV("phaser.wav");
+
+  screen = SDL_SetVideoMode(320, 240, 0, 0);
+
+  while(!done) {
+    while(SDL_PollEvent(&event)) {
+      switch(event.type) {
+      case SDL_QUIT:
+done = 1;
+break;
+      case SDL_KEYDOWN:
+      case SDL_KEYUP:
+handleKey(event.key);
+break;
+      }
+    }
+    SDL_Delay(50);
+
+  }
+
+  Mix_CloseAudio();
+  SDL_Quit();
+
+}
+
+void handleKey(SDL_KeyboardEvent key) {
+  switch(key.keysym.sym) {
+  case SDLK_p:
+
+    /* We're going to have the phaser continually fire as long as
+       the user is holding the button down */
+    if(key.type == SDL_KEYDOWN) {
+
+      if(phaserChannel < 0) {
+
+/* Mix_PlayChannel takes, as its arguments, the channel that
+   the given sound should be played on, the sound itself, and
+   the number of times it should be looped.  If you don't care
+   what channel the sound plays on, just pass in -1.  Looping
+   works like Mix_PlayMusic. This function returns the channel
+   that the sound was assigned to, which you'll need later. */
+phaserChannel = Mix_PlayChannel(-1, phaser, -1);
+
+      }
+    } else {
+      /* Mix_HaltChannel stops a certain channel from playing - this
+ is one of the reasons we kept track of which channel the
+ phaser had been assigned to */
+      Mix_HaltChannel(phaserChannel);
+      
+      phaserChannel = -1;
+    }
+    break;
+  }
+}
Index: /orxonox/branches/sound/src/demo3.c
===================================================================
--- /orxonox/branches/sound/src/demo3.c	(revision 2777)
+++ /orxonox/branches/sound/src/demo3.c	(revision 2777)
@@ -0,0 +1,98 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "SDL.h"
+#include "SDL_mixer.h"
+
+Mix_Chunk *phaser = NULL;
+Mix_Music *music = NULL;
+
+int phaserChannel = -1;
+
+void handleKey(SDL_KeyboardEvent key);
+void musicDone();
+
+int main(void) {
+
+  SDL_Surface *screen;
+  SDL_Event event;
+  int done = 0;
+
+  /* Same setup as before */
+  int audio_rate = 22050;
+  Uint16 audio_format = AUDIO_S16; 
+  int audio_channels = 2;
+  int audio_buffers = 4096;
+
+  SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
+
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
+    printf("Unable to open audio!\n");
+    exit(1);
+  }
+
+  /* Pre-load sound effects */
+  phaser = Mix_LoadWAV("phaser.wav");
+
+  screen = SDL_SetVideoMode(320, 240, 0, 0);
+
+  while(!done) {
+    while(SDL_PollEvent(&event)) {
+      switch(event.type) {
+      case SDL_QUIT:
+done = 1;
+break;
+      case SDL_KEYDOWN:
+      case SDL_KEYUP:
+handleKey(event.key);
+break;
+      }
+    }
+    SDL_Delay(50);
+
+  }
+
+  Mix_CloseAudio();
+  SDL_Quit();
+
+}
+
+void handleKey(SDL_KeyboardEvent key) {
+  switch(key.keysym.sym) {
+  case SDLK_p:
+
+    if(key.type == SDL_KEYDOWN) {
+
+      if(phaserChannel < 0) {
+phaserChannel = Mix_PlayChannel(-1, phaser, -1);
+      }
+    } else {
+      Mix_HaltChannel(phaserChannel);
+      
+      phaserChannel = -1;
+    }
+    break;
+  case SDLK_m:
+    if(key.state == SDL_PRESSED) {
+
+      if(music == NULL) {
+
+music = Mix_LoadMUS("music.ogg");
+Mix_PlayMusic(music, 0);
+Mix_HookMusicFinished(musicDone);
+
+      } else {
+Mix_HaltMusic();
+Mix_FreeMusic(music);
+music = NULL;
+      }
+    }
+    break;
+  }
+}
+
+void musicDone() {
+  Mix_HaltMusic();
+  Mix_FreeMusic(music);
+  music = NULL;
+}
Index: /orxonox/branches/sound/src/demo4.c
===================================================================
--- /orxonox/branches/sound/src/demo4.c	(revision 2777)
+++ /orxonox/branches/sound/src/demo4.c	(revision 2777)
@@ -0,0 +1,152 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "SDL.h"
+#include "SDL_mixer.h"
+#include "SDL_thread.h"
+
+Mix_Chunk *phaser = NULL;
+Mix_Music *music = NULL;
+
+int phaserChannel = -1;
+
+void handleKey(SDL_KeyboardEvent key);
+void musicDone();
+
+/*This function polls every 20 ms for new SDL_Events.
+If it finds such events, it determines type and has a behaviour for different 
+SDL_Keys. It can be called by SDL_Quit or other events.*/
+
+int main(void) {
+  SDL_Surface *screen;
+  SDL_Event event;
+  int done = 0, bits = 0, audio_rate = 44100, audio_channels = 2, 
+  audio_buffers = 4096, volume = SDL_MIX_MAXVOLUME;
+  Uint16 audio_format = AUDIO_S16; 
+
+  // Opening the sound and graphic card
+  SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) {
+    printf("Unable to open audio!\n");
+    exit(1);
+  }
+
+  // Print out some info on the audio device and stream
+  Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+  bits=audio_format&0xFF;
+  printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate, bits, audio_channels>1?"stereo":"mono", audio_buffers );
+
+  // 
+  phaser = Mix_LoadWAV("phaser.wav");
+  screen = SDL_SetVideoMode(1024,768,0,SDL_FULLSCREEN|SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF);
+  SDL_WM_SetCaption("mixer4 - SDL_mixer demo","mixer4");
+  SDL_ShowCursor(SDL_DISABLE);  
+  
+  while(!done) {
+    while(SDL_PollEvent(&event)) {
+      switch(event.type) {
+      case SDL_QUIT:
+	done = 1;
+	break;
+      case SDL_KEYDOWN:
+	switch(event.key.keysym.sym){
+
+	  // Escape and q exit the loop
+	case SDLK_ESCAPE:
+	  done = 1;
+	  break;
+	case SDLK_q:
+	  done = 1;
+	  break;
+
+	  // Restart the music 
+	case SDLK_r:
+	  Mix_RewindMusic();
+	  break;
+
+	  // For future implementation with a mp3 -> fast forward and backwards
+	case SDLK_LEFT:
+	  switch(Mix_GetMusicType(NULL))
+	    {
+	    case MUS_MP3:
+	      Mix_SetMusicPosition(-5);
+	      break;
+	    default:
+	      printf("Cannot turn back this type of music\n");
+	      break;
+	    }
+	  break;
+	case SDLK_RIGHT:
+	  switch(Mix_GetMusicType(NULL))
+	    {
+	    case MUS_MP3:
+	      Mix_SetMusicPosition(+5);
+	      break;
+	      default:
+		printf("cannot forward this type of music\n");
+		break;
+	    }
+	  break;
+
+	  // Up and down serve as volume control
+	case SDLK_UP:
+	  volume=(volume+1)<<1;
+	  if(volume>SDL_MIX_MAXVOLUME)
+	    volume=SDL_MIX_MAXVOLUME;
+	    Mix_VolumeMusic(volume);
+	    break;
+	case SDLK_DOWN:
+	  volume>>=1;
+	  Mix_VolumeMusic(volume);
+	  break;
+
+	  // Stops the music and continues the music
+	case SDLK_SPACE:
+	  if(Mix_PausedMusic())
+	    Mix_ResumeMusic();
+	  else
+	    Mix_PauseMusic();
+	  break;
+
+	  // Phaser
+	case SDLK_p:
+	  if(event.key.type == SDL_KEYDOWN) {
+	    if(phaserChannel < 0) {
+	      phaserChannel = Mix_PlayChannel(-1, phaser, -1);
+	    }
+	    else {
+	      Mix_HaltChannel(phaserChannel);
+	      phaserChannel = -1;
+	    }
+	  }
+	  break;
+
+	  // Music
+	case SDLK_m:
+	  if(event.key.state == SDL_PRESSED) {
+	    if(music == NULL) {
+	      music = Mix_LoadMUS("music.ogg");	
+	      Mix_PlayMusic(music, 0);
+	      Mix_HookMusicFinished(musicDone);
+	    } else {
+	      Mix_HaltMusic();
+	      Mix_FreeMusic(music);
+	      music = NULL;
+	    }
+	  }
+	  break;
+	default:
+	  break;
+	}
+      }
+      SDL_Delay(30);
+    }
+  }
+  Mix_CloseAudio();
+  SDL_Quit();
+}
+ 
+void musicDone() {
+  Mix_HaltMusic();
+  Mix_FreeMusic(music);
+  music = NULL;
+}
Index: /orxonox/branches/sound/src/mixer1.cpp
===================================================================
--- /orxonox/branches/sound/src/mixer1.cpp	(revision 2777)
+++ /orxonox/branches/sound/src/mixer1.cpp	(revision 2777)
@@ -0,0 +1,202 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_mixer.h"
+
+Mix_Chunk* blaster = NULL;
+Mix_Chunk* r2 = NULL;
+Mix_Chunk* sabre = NULL;
+Mix_Music* music = NULL;
+
+int bChannel = -1;
+int rChannel = -1;
+int sChannel = -1;
+
+SDL_Event event;
+
+int volume = SDL_MIX_MAXVOLUME;
+int track_number = 1;
+int done = 0;
+
+void handleKey(SDL_KeyboardEvent key);
+void musicDone();
+
+int main(int argc, char *argv[]) {
+	
+	SDL_Surface *screen;
+
+	
+	//setup parameters
+	int audio_rate = 44100, audio_channels = 2, audio_buffers = 4096, bits = 0;
+	Uint16 audio_format = AUDIO_S16;
+	
+	//initializing sound and calling Mix_OpenAudio
+	if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO)<0){
+		printf("Unable to init sound or video!\n");
+		exit(1);
+	}
+	if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){
+		printf("Unable to open audio!\n");
+		exit(1);
+	}
+	
+	// Print some info
+	Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+	bits=audio_format&0xFF;
+	printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
+		bits, audio_channels > 1 ? "stereo" : "mono", audio_buffers );
+	
+	// Pre-load sound effects
+	blaster = Mix_LoadWAV("blaster.wav");
+	r2 = Mix_LoadWAV("artoo.wav");
+	sabre = Mix_LoadWAV("sabre_on.wav");
+	
+	Mix_VolumeMusic(volume);
+	
+	//screen buildup
+	screen = SDL_SetVideoMode(320, 240, 0, 0);
+	
+	while(!done) {
+		//possible extension to looping with: if(Mix_PlayMusic(music, 1)==-1){}
+		while(SDL_PollEvent(&event)) {
+			switch(event.type){
+			case SDL_QUIT:
+				done = 1;
+				break;
+			case SDL_KEYDOWN:
+			case SDL_KEYUP:
+				handleKey(event.key);
+				break;
+			default:	
+				break;
+			}
+		}
+		SDL_Delay(50);
+	}
+	Mix_CloseAudio();
+	SDL_Quit();
+	return 0;
+}
+
+void handleKey(SDL_KeyboardEvent key) {
+	switch(event.key.keysym.sym){
+	case SDLK_ESCAPE:
+		done = 1;
+		break;
+	case SDLK_q:	
+		done = 1;
+		break;
+	case SDLK_LEFT:
+		Mix_RewindMusic();
+		break;
+	case SDLK_RIGHT:
+		switch(Mix_GetMusicType(NULL)){
+		case MUS_MP3:
+			Mix_SetMusicPosition(+5);
+			break;
+		default:
+			printf("no forwarding with this type of music.\n");
+			break;
+		}
+		break;
+	case SDLK_UP:
+		volume = (volume + 1) << 1;
+		if(volume > SDL_MIX_MAXVOLUME)
+			volume = SDL_MIX_MAXVOLUME;
+		Mix_VolumeMusic(volume);
+		break;
+	case SDLK_DOWN:
+		volume >>= 1;
+		Mix_VolumeMusic(volume);
+		break;
+	case SDLK_SPACE:
+		if(Mix_PausedMusic())
+			Mix_ResumeMusic();
+		else
+			Mix_PauseMusic();
+		break;
+	case SDLK_r:
+		if(event.key.type == SDL_KEYDOWN) {
+			if(rChannel < 0) {
+				rChannel = Mix_PlayChannel(-1, r2, -1);
+			}
+		} else {
+			Mix_HaltChannel(rChannel);
+			rChannel = -1;
+		}
+		break;
+	case SDLK_b:
+		if(event.key.type == SDL_KEYDOWN) {
+			if(bChannel < 0) {
+				bChannel = Mix_PlayChannel(-1, blaster, -1);
+			}
+		} else {
+			Mix_HaltChannel(bChannel);
+			bChannel = -1;
+		}
+		break;
+	case SDLK_s:
+		if(event.key.type == SDL_KEYDOWN) {
+			if(sChannel < 0) {
+				sChannel = Mix_PlayChannel(-1, sabre, -1);
+			}
+		} else {
+			Mix_HaltChannel(bChannel);
+			sChannel = -1;
+		}
+		break;
+	case SDLK_m:
+		if(event.key.state == SDL_PRESSED) {
+			if(music == NULL) { 
+				switch (track_number){
+				case 1:
+					music = Mix_LoadMUS("luke_grey_orxonox1.ogg");
+					Mix_PlayMusic(music, 0);
+					Mix_HookMusicFinished(musicDone);
+					track_number++;
+					break;
+				case 2:
+					music = Mix_LoadMUS("luke_grey_orxonox2.ogg");
+					Mix_PlayMusic(music, 0);
+					Mix_HookMusicFinished(musicDone);
+					track_number++;
+					break;
+				case 3:
+					music = Mix_LoadMUS("luke_grey_orxonox3.ogg");
+					Mix_PlayMusic(music, 0);
+					Mix_HookMusicFinished(musicDone);
+					track_number++;
+					break;
+				case 4:
+					music = Mix_LoadMUS("luke_grey_and aquarius_orxonox.ogg");
+					Mix_PlayMusic(music, 0);
+					Mix_HookMusicFinished(musicDone);
+					track_number++;
+					break;
+				case 5:
+					music = Mix_LoadMUS("nomenes_orxonox.ogg");
+					Mix_PlayMusic(music, 0);
+					Mix_HookMusicFinished(musicDone);
+					track_number = 1;
+					break;
+				}
+			} else {
+				Mix_HaltMusic();
+				Mix_FreeMusic(music);
+				music = NULL;
+			}
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+void musicDone() {
+	Mix_HaltMusic();
+	Mix_FreeMusic(music);
+	music = NULL;
+}
Index: /orxonox/branches/sound/src/mixer2.cpp
===================================================================
--- /orxonox/branches/sound/src/mixer2.cpp	(revision 2777)
+++ /orxonox/branches/sound/src/mixer2.cpp	(revision 2777)
@@ -0,0 +1,213 @@
+#include "SDL.h"
+#include "SDL_thread.h"
+#include "SDL_mixer.h"
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+Sint16 stream[2][4096];
+int len=4096, done=0, need_refresh=0, bits=0, which=0;
+SDL_Surface *s=NULL;
+Uint32 flips=0;
+Uint32 black,white;
+float dy,dx;
+
+/******************************************************************************/
+/* some simple exit and error routines                                        */
+
+void errorv(char *str, va_list ap)
+{
+	vfprintf(stderr,str,ap);
+	fprintf(stderr,": %s.\n", SDL_GetError());
+}
+
+void cleanExit(char *str,...)
+{
+	va_list ap;
+	va_start(ap, str);
+	errorv(str,ap);
+	va_end(ap);
+	Mix_CloseAudio();
+	SDL_Quit();
+	exit(1);
+}
+
+/******************************************************************************/
+/* the postmix processor, only copies the stream buffer and indicates         */
+/* a need for a screen refresh                                                */
+
+static void postmix(void *udata, Uint8 *_stream, int _len)
+{
+	// save the stream buffer and indicate that we need a redraw
+	len=_len;
+	memcpy(stream[(which+1)%2],_stream,len>s->w*4?s->w*4:len);
+	which=(which+1)%2;
+	need_refresh=1;
+}
+
+/******************************************************************************/
+/* redraw the wav and reset the need_refresh indicator                        */
+
+void refresh()
+{
+	int x,y,Y;
+	Sint16 *buf;
+
+	buf=stream[which];
+	need_refresh=0;
+	
+	// clear the screen
+	SDL_FillRect(s,NULL,black);
+
+	// draw the wav from the saved stream buffer
+	Y=s->h/4;
+	for(x=0;x<s->w*2;x++)
+	{
+		y=(buf[x]*dy);
+		{
+			if(y<0)
+			{
+				SDL_Rect r={x/2,Y+y,1,-y};
+				SDL_FillRect(s,&r,white);
+			}
+			else
+			{
+				SDL_Rect r={x/2,Y,1,y};
+				SDL_FillRect(s,&r,white);
+			}
+		}
+		Y=Y>s->h/2?s->h/4:s->h*3/4;
+	}
+	SDL_Flip(s);
+	flips++;
+}
+
+/******************************************************************************/
+
+int main(int argc, char **argv)
+{
+	int audio_rate,audio_channels,
+		// set this to any of 512,1024,2048,4096
+		// the higher it is, the more FPS shown and CPU needed
+		audio_buffers=512;
+	Uint16 audio_format;
+	Uint32 t;
+	Mix_Music *music;
+	int volume=SDL_MIX_MAXVOLUME;
+
+	// initialize SDL for audio and video
+	if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO)<0)
+		cleanExit("SDL_Init");
+
+	// open a screen for the wav output
+	//if(!(s=SDL_SetVideoMode(1024,768,0,SDL_FULLSCREEN|SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF)))
+	if(!(s=SDL_SetVideoMode(512,512,0,SDL_ANYFORMAT|SDL_DOUBLEBUF)))
+		cleanExit("SDL_SetVideoMode");
+	SDL_WM_SetCaption("sdlwav - SDL_mixer demo","sdlwav");
+	
+	// hide the annoying mouse pointer
+	SDL_ShowCursor(SDL_DISABLE);
+	// get the colors we use
+	white=SDL_MapRGB(s->format,0xff,0xff,0xff);
+	black=SDL_MapRGB(s->format,0,0,0);
+	
+	// initialize sdl mixer, open up the audio device
+	if(Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,2,audio_buffers)<0)
+		cleanExit("Mix_OpenAudio");
+
+	// print out some info on the audio device and stream
+	Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+	bits=audio_format&0xFF;
+	printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
+			bits, audio_channels>1?"stereo":"mono", audio_buffers );
+
+	// calculate some parameters for the wav display
+	dy=s->h/2.0/(float)(0x1<<bits);
+	dx=s->w/(float)(0x1<<bits);
+	
+	// load the song
+	if(!(music=Mix_LoadMUS(argv[1])))
+		cleanExit("Mix_LoadMUS(\"%s\")",argv[1]);
+	
+	// set the post mix processor up
+	Mix_SetPostMix(postmix,argv[1]);
+	
+	// start playing and displaying the wav
+	// wait for escape key of the quit event to finish
+	t=SDL_GetTicks();
+	if(Mix_PlayMusic(music, 1)==-1)
+		cleanExit("Mix_PlayMusic(0x%p,1)",music);
+	Mix_VolumeMusic(volume);
+
+	while((Mix_PlayingMusic() || Mix_PausedMusic()) && !done)
+	{
+		SDL_Event e;
+		while(SDL_PollEvent(&e))
+		{
+			switch(e.type)
+			{
+				case SDL_KEYDOWN:
+					switch(e.key.keysym.sym)
+					{
+						case SDLK_ESCAPE:
+							done=1;
+							break;
+						case SDLK_LEFT:
+							Mix_RewindMusic();
+							break;
+						case SDLK_RIGHT:
+							switch(Mix_GetMusicType(NULL))
+							{
+								case MUS_MP3:
+									Mix_SetMusicPosition(+5);
+									break;
+								default:
+									printf("cannot fast-forward this type of music\n");
+									break;
+							}
+							break;
+						case SDLK_UP:
+							volume=(volume+1)<<1;
+							if(volume>SDL_MIX_MAXVOLUME)
+								volume=SDL_MIX_MAXVOLUME;
+							Mix_VolumeMusic(volume);
+							break;
+						case SDLK_DOWN:
+							volume>>=1;
+							Mix_VolumeMusic(volume);
+							break;
+						case SDLK_SPACE:
+							if(Mix_PausedMusic())
+								Mix_ResumeMusic();
+							else
+								Mix_PauseMusic();
+							break;
+						default:
+							break;
+					}
+					break;
+				case SDL_QUIT:
+					done=1;
+					break;
+				default:
+					break;
+			}
+		}
+		// the postmix processor tells us when there's new data to draw
+		if(need_refresh)
+			refresh();
+		else
+			SDL_Delay(0);
+	}
+	t=SDL_GetTicks()-t;
+	
+	// free & close
+	Mix_FreeMusic(music);
+	Mix_CloseAudio();
+	SDL_Quit();
+	// show a silly statistic
+	printf("fps=%.2f\n",((float)flips)/(t/1000.0));
+	return(0);
+}
Index: /orxonox/branches/sound/src/sdlwav.c
===================================================================
--- /orxonox/branches/sound/src/sdlwav.c	(revision 2777)
+++ /orxonox/branches/sound/src/sdlwav.c	(revision 2777)
@@ -0,0 +1,214 @@
+#include "SDL.h"
+#include "SDL_thread.h"
+#include "SDL_mixer.h"
+
+#include <stdarg.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+Sint16 stream[2][4096];
+int len=4096, done=0, need_refresh=0, bits=0, which=0;
+SDL_Surface *s=NULL;
+Uint32 flips=0;
+Uint32 black,white;
+float dy,dx;
+
+/******************************************************************************/
+/* some simple exit and error routines                                        */
+
+void errorv(char *str, va_list ap)
+{
+	vfprintf(stderr,str,ap);
+	fprintf(stderr,": %s.\n", SDL_GetError());
+}
+
+void cleanExit(char *str,...)
+{
+	va_list ap;
+	va_start(ap, str);
+	errorv(str,ap);
+	va_end(ap);
+	Mix_CloseAudio();
+	SDL_Quit();
+	exit(1);
+}
+
+/******************************************************************************/
+/* the postmix processor, only copies the stream buffer and indicates         */
+/* a need for a screen refresh                                                */
+
+static void postmix(void *udata, Uint8 *_stream, int _len)
+{
+	// save the stream buffer and indicate that we need a redraw
+	len=_len;
+	memcpy(stream[(which+1)%2],_stream,len>s->w*4?s->w*4:len);
+	which=(which+1)%2;
+	need_refresh=1;
+}
+
+/******************************************************************************/
+/* redraw the wav and reset the need_refresh indicator                        */
+
+void refresh()
+{
+	int x,y,Y;
+	Sint16 *buf;
+
+	buf=stream[which];
+	need_refresh=0;
+	
+	// clear the screen
+	SDL_FillRect(s,NULL,black);
+
+	// draw the wav from the saved stream buffer
+	Y=s->h/4;
+	for(x=0;x<s->w*2;x++)
+	{
+		y=(buf[x]*dy);
+		{
+			if(y<0)
+			{
+				SDL_Rect r={x/2,Y+y,1,-y};
+				SDL_FillRect(s,&r,white);
+			}
+			else
+			{
+				SDL_Rect r={x/2,Y,1,y};
+				SDL_FillRect(s,&r,white);
+			}
+		}
+		Y=Y>s->h/2?s->h/4:s->h*3/4;
+	}
+	SDL_Flip(s);
+	flips++;
+}
+
+/******************************************************************************/
+
+int main(int argc, char **argv)
+{
+	int audio_rate,audio_channels,
+		// set this to any of 512,1024,2048,4096
+		// the higher it is, the more FPS shown and CPU needed
+		audio_buffers=512;
+	Uint16 audio_format;
+	Uint32 t;
+	Mix_Music *music;
+	int volume=SDL_MIX_MAXVOLUME;
+
+	// initialize SDL for audio and video
+	if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO)<0)
+		cleanExit("SDL_Init");
+
+	// open a screen for the wav output
+	//if(!(s=SDL_SetVideoMode(1024,768,0,SDL_FULLSCREEN|SDL_ANYFORMAT|SDL_HWSURFACE|SDL_DOUBLEBUF)))
+	if(!(s=SDL_SetVideoMode(512,512,0,SDL_ANYFORMAT|SDL_DOUBLEBUF)))
+		cleanExit("SDL_SetVideoMode");
+	SDL_WM_SetCaption("sdlwav - SDL_mixer demo","sdlwav");
+	
+	// hide the annoying mouse pointer
+	SDL_ShowCursor(SDL_DISABLE);
+	// get the colors we use
+	white=SDL_MapRGB(s->format,0xff,0xff,0xff);
+	black=SDL_MapRGB(s->format,0,0,0);
+	
+	// initialize sdl mixer, open up the audio device
+	if(Mix_OpenAudio(44100,MIX_DEFAULT_FORMAT,2,audio_buffers)<0)
+		cleanExit("Mix_OpenAudio");
+
+	// print out some info on the audio device and stream
+	Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
+	bits=audio_format&0xFF;
+	printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
+			bits, audio_channels>1?"stereo":"mono", audio_buffers );
+
+	// calculate some parameters for the wav display
+	dy=s->h/2.0/(float)(0x1<<bits);
+	dx=s->w/(float)(0x1<<bits);
+	
+	// load the song
+	if(!(music=Mix_LoadMUS(argv[1])))
+		cleanExit("Mix_LoadMUS(\"%s\")",argv[1]);
+	
+	// set the post mix processor up
+	Mix_SetPostMix(postmix,argv[1]);
+	
+	// start playing and displaying the wav
+	// wait for escape key of the quit event to finish
+	t=SDL_GetTicks();
+	if(Mix_PlayMusic(music, 1)==-1)
+		cleanExit("Mix_PlayMusic(0x%p,1)",music);
+	Mix_VolumeMusic(volume);
+
+	while((Mix_PlayingMusic() || Mix_PausedMusic()) && !done)
+	{
+		SDL_Event e;
+		while(SDL_PollEvent(&e))
+		{
+			switch(e.type)
+			{
+				case SDL_KEYDOWN:
+					switch(e.key.keysym.sym)
+					{
+						case SDLK_ESCAPE:
+							done=1;
+							break;
+						case SDLK_LEFT:
+							Mix_RewindMusic();
+							break;
+						case SDLK_RIGHT:
+							switch(Mix_GetMusicType(NULL))
+							{
+								case MUS_MP3:
+									Mix_SetMusicPosition(+5);
+									break;
+								default:
+									printf("cannot fast-forward this type of music\n");
+									break;
+							}
+							break;
+						case SDLK_UP:
+							volume=(volume+1)<<1;
+							if(volume>SDL_MIX_MAXVOLUME)
+								volume=SDL_MIX_MAXVOLUME;
+							Mix_VolumeMusic(volume);
+							break;
+						case SDLK_DOWN:
+							volume>>=1;
+							Mix_VolumeMusic(volume);
+							break;
+						case SDLK_SPACE:
+							if(Mix_PausedMusic())
+								Mix_ResumeMusic();
+							else
+								Mix_PauseMusic();
+							break;
+						default:
+							break;
+					}
+					break;
+				case SDL_QUIT:
+					done=1;
+					break;
+				default:
+					break;
+			}
+		}
+		// the postmix processor tells us when there's new data to draw
+		if(need_refresh)
+			refresh();
+		else
+			SDL_Delay(0);
+	}
+	t=SDL_GetTicks()-t;
+	
+	// free & close
+	Mix_FreeMusic(music);
+	Mix_CloseAudio();
+	SDL_Quit();
+	// show a silly statistic
+	printf("fps=%.2f\n",((float)flips)/(t/1000.0));
+	return(0);
+}
Index: /orxonox/branches/sound/src/sound_control.cc
===================================================================
--- /orxonox/branches/sound/src/sound_control.cc	(revision 2777)
+++ /orxonox/branches/sound/src/sound_control.cc	(revision 2777)
@@ -0,0 +1,219 @@
+/* 
+   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: Simon Hofmann 
+   co-programmer:
+*/
+
+#include "Sound_control.h"
+#include <string.h> 
+#include "SDL_mixer.h" 
+
+using namespace std;
+
+
+/** 
+    \brief standard constructor 
+    
+    This constructor builds a SoundControl Object, which waits for callers 
+    calling its functions to output sound. All sound output is handles by this  
+    object, which must only be constructed once. 
+*/ 
+SoundControl::SoundControl () { 
+  
+  //setup parameters 
+  int audio_rate = MIX_DEFAULT_FREQUENCY, audio_channels = MIX_DEFAULT_CHANNELS, audio_buffers = 8192, bits = 0; 
+  Uint16 audio_format = MIX_DEFAULT_FORMAT; 
+  Mix_Music* music = NULL; 
+  
+  //initializing sound and calling Mix_OpenAudio 
+  if(SDL_Init(SDL_INIT_AUDIO)<0){ 
+    printf("SDL_Init:\n"); 
+    exit(1); 
+  } 
+
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){ 
+    printf("Mix_OpenAudio:\n"); 
+    exit(1); 
+  } 
+
+  postConstruction();
+}
+
+
+/** 
+    \brief standard destructor 
+*/ 
+SoundControl::~SoundControl () { 
+}
+
+
+/** 
+    \brief Is called by SoundControl object to initiate all values 
+*/ 
+void SoundControl::postConstruction () { 
+  
+  // Print some info 
+  Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); 
+  bits=audio_format&0xFF; 
+  printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate, 
+	 bits, audio_channels > 1 ? "stereo" : "mono", audio_buffers ); 
+  
+  int volume = SDL_MIX_MAXVOLUME;
+  Mix_VolumeMusic(volume);
+  int track_number = 1;
+  int done = 0;
+  int free = 1;
+} 
+
+
+/** 
+    \brief Returns false if a sound_control object has been made
+*/ 
+void SoundControl::isFree () { 
+  return free;
+}
+
+
+/** 
+    \brief Sets the number of output Channels
+*/ 
+void SoundControl::setNumberOfChannels (int number_of_channels) { 
+  Mix_AllocateChannels(number_of_channels);
+} 
+
+
+/** 
+    \brief May be called from any WorldEntity to play a .xm file 
+    \param filename: self-explanatory 
+*/ 
+void SoundControl::playMod (char* fileName) {
+
+}
+
+
+/** 
+    \brief May be called from any WorldEntity to play a .wav file 
+    \param filename: self-explanatory 
+*/ 
+void SoundControl::playWav (char* fileName) {
+  Mix_Chunk* chunk = NULL; 
+  chunk = Mix_LoadWAV(fileName); 
+  if(Mix_PlayChannel(-1, chunk, 0) == -1) {
+    printf("Mix_PlayChannel: %s\n", Mix_GetError());
+  }
+} 
+
+
+/** 
+    \brief May be called from any WorldEntity to play a .ogg file 
+    \param filename: self-explanatory 
+*/ 
+void SoundControl::playOgg (char* fileName) {
+  Mix_Music* music = NULL;
+  music = Mix_LoadMUS(fileName);
+  if(Mix_PlayMusic(music, 1) == -1){
+    printf("Mix_PlayMusic: %s\n",Mix_GetError());
+  }
+  Mix_HookMusicFinished(musicDone);
+} 
+
+
+/** 
+    \brief Heightens the overall volume of output 
+*/ 
+void SoundControl::volumeUp () { 
+  volume = (volume + 1) << 1; 
+  if(volume > SDL_MIX_MAXVOLUME) 
+    volume = SDL_MIX_MAXVOLUME; 
+  Mix_VolumeMusic(volume); 
+} 
+
+
+/** 
+    \brief Lowers the overall volume of output 
+*/  
+void SoundControl::volumeDown () { 
+  volume >>= 1; 
+  Mix_VolumeMusic(volume); 
+} 
+
+
+/** 
+    \brief Rewinds music to the beginning 
+*/  
+void SoundControl::trackRewind () { 
+  Mix_RewindMusic(); 
+} 
+
+
+/** 
+    \brief Rewinds the music 5 seconds 
+*/  
+void SoundControl::forwardMusic () { 
+  Mix_SetMusicPosition(+5); 
+} 
+
+
+/** 
+    \brief Forwards the music 5 seconds 
+*/  
+void SoundControl::rewindMusic () { 
+  Mix_SetMusicPosition(-5); 
+} 
+
+
+/** 
+    \brief Pauses music output 
+*/ 
+void SoundControl::pauseMusic () {
+  Mix_PauseMusic()
+} 
+
+
+/** 
+    \brief this function pauses music output 
+*/ 
+void SoundControl::resumeMusic () {
+  Mix_ResumeMusic()
+} 
+
+/** 
+    \brief Selects the track of all orxonox tracks 
+*/
+void SoundControl::trackSelect () { 
+  switch (track_number) { 
+  case 1: 
+    music = Mix_LoadMUS("luke_grey_orxonox1.ogg"); 
+    break; 
+  case 2: 
+    music = Mix_LoadMUS("luke_grey_orxonox2.ogg"); 
+    break; 
+  case 3: 
+    music = Mix_LoadMUS("luke_grey_orxonox3.ogg"); 
+    break; 
+  case 4: 
+    music = Mix_LoadMUS("luke_grey_and aquarius_orxonox.ogg"); 
+    break; 
+  case 5: 
+    music = Mix_LoadMUS("nomenes_orxonox.ogg"); 
+    break; 
+  } 
+}
+
+
+/** 
+    \brief Called by playOgg 
+*/ 
+void SoundControl::musicDone () {
+  track_number++; 
+} 
+
Index: /orxonox/branches/sound/src/sound_control.h
===================================================================
--- /orxonox/branches/sound/src/sound_control.h	(revision 2777)
+++ /orxonox/branches/sound/src/sound_control.h	(revision 2777)
@@ -0,0 +1,16 @@
+
+#ifndef PROTO_CLASS_H
+#define PROTO_CLASS_H
+
+#include "data_tank.h"
+
+
+class ProtoClass {
+
+ public:
+  ProtoClass ();
+  ~ProtoClass ();
+
+};
+
+#endif
