Index: orxonox/branches/soundEngine/config.h.in
===================================================================
--- orxonox/branches/soundEngine/config.h.in	(revision 3507)
+++ orxonox/branches/soundEngine/config.h.in	(revision 3508)
@@ -59,4 +59,7 @@
 #undef HAVE_SDL_SDL_IMAGE_H
 
+/* Define to 1 if you have the <SDL/SDL_mixer.h> header file. */
+#undef HAVE_SDL_SDL_MIXER_H
+
 /* Define to 1 if you have the `sqrt' function. */
 #undef HAVE_SQRT
Index: orxonox/branches/soundEngine/configure
===================================================================
--- orxonox/branches/soundEngine/configure	(revision 3507)
+++ orxonox/branches/soundEngine/configure	(revision 3508)
@@ -6051,4 +6051,235 @@
 ## CHECKING FOR HEADERS AND LIBS ##
 ###################################
+
+#-----------#
+# SDL_mixer #
+#-----------#
+
+for ac_header in SDL/SDL_mixer.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ---------------------------------------------- ##
+## Report this to orxonox-dev at mail.datacore.ch ##
+## ---------------------------------------------- ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  { { echo "$as_me:$LINENO: error: sdl_mixer not found" >&5
+echo "$as_me: error: sdl_mixer not found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+done
+
+# checking for SDL_mixer-lib
+echo "$as_me:$LINENO: checking for main in -lSDL_mixer" >&5
+echo $ECHO_N "checking for main in -lSDL_mixer... $ECHO_C" >&6
+if test "${ac_cv_lib_SDL_mixer_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lSDL_mixer  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_SDL_mixer_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_SDL_mixer_main=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_mixer_main" >&5
+echo "${ECHO_T}$ac_cv_lib_SDL_mixer_main" >&6
+if test $ac_cv_lib_SDL_mixer_main = yes; then
+  FOUND_SDL_mixer=yes
+fi
+
+   if test x$FOUND_SDL_mixer = xyes ; then
+     LIBS="$LIBS -lSDL_mixer"
+   else
+      echo "------------------"
+      echo "SDL_mixer library not found."
+      echo "please install the SDL_mixer library, which can be found at http://www.libsdl.org/projects/SDL_mixer/"
+      echo "------------------"
+      exit -1
+   fi
+
 
 #-----------#
Index: orxonox/branches/soundEngine/configure.ac
===================================================================
--- orxonox/branches/soundEngine/configure.ac	(revision 3507)
+++ orxonox/branches/soundEngine/configure.ac	(revision 3508)
@@ -367,4 +367,22 @@
 
 #-----------#
+# SDL_mixer #
+#-----------#
+AC_CHECK_HEADERS([SDL/SDL_mixer.h] ,,
+      [AC_MSG_ERROR([sdl_mixer not found])])
+# checking for SDL_mixer-lib
+AC_CHECK_LIB([SDL_mixer], [main], [FOUND_SDL_mixer=yes])
+   if test x$FOUND_SDL_mixer = xyes ; then
+     LIBS="$LIBS -lSDL_mixer"
+   else
+      echo "------------------"
+      echo "SDL_mixer library not found."
+      echo "please install the SDL_mixer library, which can be found at http://www.libsdl.org/projects/SDL_mixer/"
+      echo "------------------"
+      exit -1
+   fi   
+
+
+#-----------#
 # SDL_Image #
 #-----------#
Index: orxonox/branches/soundEngine/src/Makefile.am
===================================================================
--- orxonox/branches/soundEngine/src/Makefile.am	(revision 3507)
+++ orxonox/branches/soundEngine/src/Makefile.am	(revision 3508)
@@ -25,5 +25,5 @@
 
 
-bin_PROGRAMS=orxonox
+bin_PROGRAMS=orxonox sound
 
 orxonox_SOURCES= orxonox.cc \
@@ -60,4 +60,6 @@
 		 lib/math/curve.cc \
 		 glmenu/glmenu_imagescreen.cc 
+
+sound_SOURCES = sound_control.cc
 
 noinst_HEADERS = orxonox.h \
Index: orxonox/branches/soundEngine/src/sound_control.cc
===================================================================
--- orxonox/branches/soundEngine/src/sound_control.cc	(revision 3508)
+++ orxonox/branches/soundEngine/src/sound_control.cc	(revision 3508)
@@ -0,0 +1,261 @@
+/* 
+   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"
+
+using namespace std;
+
+int sfx_channel1 = -1;
+int sfx_channel2 = -1;
+int finished = 0;
+SoundControl* SoundControl::sound = SoundControl::getInstance();
+SoundControl* SoundControl::singletonRef = 0;
+int volume = SDL_MIX_MAXVOLUME;
+int track_number = 1;
+Mix_Music* music = NULL;
+int audio_rate = 44100, audio_channels = MIX_DEFAULT_CHANNELS, 
+audio_buffers = 16384, bits = 0; 
+Uint16 audio_format = MIX_DEFAULT_FORMAT;
+SDL_Event event;
+
+
+/** 
+    \brief standard constructor 
+    This constructor builds a SoundControl Object and initialises it .
+    All sound output is handled by this singleton object.
+*/ 
+SoundControl::SoundControl() { 
+  if(SDL_Init(SDL_INIT_AUDIO)<0) {
+    printf("SDL_Init: INIT_AUDIO error.\n"); 
+  } 
+  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)) { 
+    printf("Mix_OpenAudio: Failed to open audio!\n"); 
+  } 
+  initialise();
+}
+
+/** 
+    \brief Default destructor 
+*/ 
+SoundControl::~SoundControl() {
+}
+
+/**
+   \brief Returns a reference to the SoundControl singleton
+*/
+SoundControl* SoundControl::getInstance() {
+  if (!SoundControl::singletonRef) 
+    return singletonRef;
+  else
+    return singletonRef = new SoundControl;
+}
+
+/** 
+    \brief Is called by SoundControl object to initiate all values and to output some text
+*/ 
+void SoundControl::initialise() { 
+  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 ); 
+  Mix_VolumeMusic(volume);
+} 
+
+/** 
+    \brief Sets the number of output Channels
+*/ 
+void SoundControl::setNumberOfChannels(int number_of_channels) { 
+  Mix_AllocateChannels(number_of_channels);
+} 
+
+/** 
+    \brief Static function to play a .xm file 
+    \param filename: self-explanatory 
+*/ 
+void SoundControl::playMod(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 Static function 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 Static function to play an .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 Pauses music output 
+*/ 
+void SoundControl::resumeMusic() {
+  Mix_ResumeMusic();
+} 
+
+/** 
+    \brief Fades in music
+*/ 
+void fadeInMusic(int time) {
+
+}
+
+/** 
+    \brief Fades out music
+*/ 
+void SoundControl::fadeOutMusic(int time) {
+
+}
+
+/** 
+    \brief Hooked by playOgg at end of .ogg playback
+*/ 
+void SoundControl::musicDone() {
+  Mix_HaltMusic();
+  Mix_FreeMusic(music);
+  music = NULL;
+} 
+
+/** 
+    \brief Handles input events
+*/ 
+void SoundControl::handleKey(SDL_KeyboardEvent key) {
+  SoundControl* sound = SoundControl::getInstance();
+
+  switch(key.keysym.sym) {
+  case SDLK_a:
+    if(key.type == SDL_KEYDOWN) {
+      if(sound->sfx_channel1 < 0) {
+	sound->sfx_channel1 = 1;
+	sound->playWav("sound1.wav");
+      }
+    } else {
+      Mix_HaltChannel(sound->sfx_channel1);
+      sound->sfx_channel1 = -1;
+    }
+    break;
+  case SDLK_s:
+    if(key.type == SDL_KEYDOWN) {
+      if(sound->sfx_channel2 < 0) {
+	sound->sfx_channel2 = 1;
+	sound->playWav("sound2.wav");
+      }
+    } else {
+      Mix_HaltChannel(sound->sfx_channel2);
+      sound->sfx_channel2 = -1;
+    }
+    break;
+  case SDLK_m:
+    if(key.state == SDL_PRESSED) {
+      sound->playOgg("music.ogg");
+    }
+    break;
+  case SDLK_q:
+    sound->finished = 1;
+    break;
+  default:
+    break;
+  }
+}
+
+int main(int argc, char* argv[]) {
+  SDL_Surface* screen;
+  SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); 
+  screen = SDL_SetVideoMode(320, 240, 0, 0);
+  while(!finished) {
+    while(SDL_PollEvent(&event)) {
+      switch(event.type) {
+      case SDL_QUIT:
+	finished = 1;
+	break;
+      case SDL_KEYDOWN:
+      case SDL_KEYUP:
+	SoundControl::handleKey(event.key);
+	break;
+      default:
+	break;
+      }
+    }
+    SDL_Delay(50);
+  }
+  delete SoundControl::getInstance();
+  SDL_Quit();
+  return 0;
+}
Index: orxonox/branches/soundEngine/src/sound_control.h
===================================================================
--- orxonox/branches/soundEngine/src/sound_control.h	(revision 3508)
+++ orxonox/branches/soundEngine/src/sound_control.h	(revision 3508)
@@ -0,0 +1,50 @@
+#ifndef SOUNDCONTROL_CLASS_H
+#define SOUNDCONTROL_CLASS_H
+
+#include <SDL/SDL.h>
+#include <SDL/SDL_mixer.h>
+#include <stdio.h>
+
+class SoundControl {
+ public:
+  ~SoundControl();
+
+  static SoundControl* getInstance();
+  
+  void setNumberOfChannels(int number_of_channels);
+  static void playMod(char* filename);
+  static void playWav(char* filename);
+  static void playOgg(char* filename);
+  void volumeUp();
+  void volumeDown();
+  void trackRewind();
+  void forwardMusic();
+  void rewindMusic();
+  void pauseMusic();
+  void resumeMusic();
+  void fadeInMusic(int time);
+  void fadeOutMusic(int time);
+  static void musicDone();
+  
+  static void handleKey(SDL_KeyboardEvent key); 
+  int main(int argc, char* argv[]);
+  
+  static SoundControl* sound;
+  int volume;
+  int track_number;
+  int audio_rate, audio_channels, audio_buffers;
+  int done;
+  Uint16 audio_format;
+  int sfx_channel1;
+  int sfx_channel2;
+  int finished;
+
+ private:
+  SoundControl();
+
+  static SoundControl* singletonRef;
+  void initialise();
+
+};
+
+#endif
