[Orxonox-commit 492] r3055 - in branches/sound2/src/orxonox: . gamestates sound
erwin at orxonox.net
erwin at orxonox.net
Mon May 25 13:53:14 CEST 2009
Author: erwin
Date: 2009-05-25 13:53:13 +0200 (Mon, 25 May 2009)
New Revision: 3055
Added:
branches/sound2/src/orxonox/sound/SoundMainMenu.cc
branches/sound2/src/orxonox/sound/SoundMainMenu.h
Modified:
branches/sound2/src/orxonox/CameraManager.h
branches/sound2/src/orxonox/OrxonoxPrereqs.h
branches/sound2/src/orxonox/gamestates/GSMainMenu.cc
branches/sound2/src/orxonox/gamestates/GSMainMenu.h
branches/sound2/src/orxonox/sound/CMakeLists.txt
branches/sound2/src/orxonox/sound/SoundBase.cc
branches/sound2/src/orxonox/sound/SoundBase.h
branches/sound2/src/orxonox/sound/SoundManager.cc
branches/sound2/src/orxonox/sound/SoundManager.h
Log:
added mainmenu ambient sound
Modified: branches/sound2/src/orxonox/CameraManager.h
===================================================================
--- branches/sound2/src/orxonox/CameraManager.h 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/CameraManager.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -55,6 +55,7 @@
void releaseFocus(Camera* camera);
static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+ static CameraManager* getInstancePtr() { return singletonRef_s; }
void useCamera(Ogre::Camera* camera);
Modified: branches/sound2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/sound2/src/orxonox/OrxonoxPrereqs.h 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/OrxonoxPrereqs.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -252,7 +252,8 @@
//sound
class SoundBase;
- class SoundManger;
+ class SoundManager;
+ class SoundMainMenu;
}
namespace Ogre
Modified: branches/sound2/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- branches/sound2/src/orxonox/gamestates/GSMainMenu.cc 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/gamestates/GSMainMenu.cc 2009-05-25 11:53:13 UTC (rev 3055)
@@ -39,6 +39,7 @@
#include "gui/GUIManager.h"
#include "objects/Scene.h"
#include "GraphicsManager.h"
+#include "sound/SoundMainMenu.h"
namespace orxonox
{
@@ -78,10 +79,15 @@
}
InputManager::getInstance().requestEnterState("mainMenu");
+
+ this->ambient_ = new SoundMainMenu();
+ this->ambient_->play(true);
}
void GSMainMenu::deactivate()
{
+ delete this->ambient_;
+
InputManager::getInstance().requestLeaveState("mainMenu");
InputManager::getInstance().requestDestroyState("mainMenu");
Modified: branches/sound2/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- branches/sound2/src/orxonox/gamestates/GSMainMenu.h 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/gamestates/GSMainMenu.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -54,6 +54,9 @@
// console commands
ConsoleCommand* ccStartGame_;
+
+ // ambient sound for the main menu
+ SoundMainMenu* ambient_;
};
}
Modified: branches/sound2/src/orxonox/sound/CMakeLists.txt
===================================================================
--- branches/sound2/src/orxonox/sound/CMakeLists.txt 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/sound/CMakeLists.txt 2009-05-25 11:53:13 UTC (rev 3055)
@@ -1,8 +1,10 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
SoundManager.h
SoundBase.h
+ SoundMainMenu.h
SoundManager.cc
SoundBase.cc
+ SoundMainMenu.cc
)
Modified: branches/sound2/src/orxonox/sound/SoundBase.cc
===================================================================
--- branches/sound2/src/orxonox/sound/SoundBase.cc 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/sound/SoundBase.cc 2009-05-25 11:53:13 UTC (rev 3055)
@@ -147,17 +147,21 @@
COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
if(filename.find("ogg", 0) != std::string::npos)
{
+ COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
this->buffer_ = loadOggFile(filename);
}
- if(this->buffer_ == AL_NONE)
+ if(this->buffer_ == AL_NONE)
+ {
+ COUT(2) << "Sound: fallback ogg loader failed: " << alutGetErrorString(alutGetError()) << std::endl;
return false;
+ }
}
alGenSources(1, &this->source_);
alSourcei(this->source_, AL_BUFFER, this->buffer_);
if(alGetError() != AL_NO_ERROR) {
- COUT(2) << "Sound: OpenAL: Error loading sample file" << std::endl;
+ COUT(2) << "Sound: OpenAL: Error loading sample file: " << filename << std::endl;
return false;
}
return true;
@@ -171,8 +175,6 @@
ALuint SoundBase::loadOggFile(std::string filename)
{
- COUT(2) << "Sound: Trying fallback ogg loader";
-
char inbuffer[4096];
std::vector<char> outbuffer;
OggVorbis_File vf;
@@ -206,7 +208,7 @@
outbuffer.insert(outbuffer.end(), inbuffer, inbuffer + sizeof(inbuffer));
}
}
-
+
ov_clear(&vf);
return alutCreateBufferFromFileImage(&outbuffer, outbuffer.size());
Modified: branches/sound2/src/orxonox/sound/SoundBase.h
===================================================================
--- branches/sound2/src/orxonox/sound/SoundBase.h 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/sound/SoundBase.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -31,11 +31,10 @@
#include <AL/al.h>
#include <string>
+#include "OrxonoxPrereqs.h"
+
namespace orxonox
{
- class SoundManager;
- class WorldEntity;
-
/**
* The SoudBase class is the base class for all sound file loader classes.
* It server as main interface to the OpenAL library.
Added: branches/sound2/src/orxonox/sound/SoundMainMenu.cc
===================================================================
--- branches/sound2/src/orxonox/sound/SoundMainMenu.cc (rev 0)
+++ branches/sound2/src/orxonox/sound/SoundMainMenu.cc 2009-05-25 11:53:13 UTC (rev 3055)
@@ -0,0 +1,46 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Erwin 'vaiursch' Herrsche
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "SoundMainMenu.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+ SoundMainMenu::SoundMainMenu()
+ {
+ RegisterObject(SoundMainMenu);
+ setConfigValues();
+ loadFile(this->filename_);
+ }
+
+ void SoundMainMenu::setConfigValues()
+ {
+ SetConfigValue(filename_, "ambient/mainmenu.wav");
+ }
+}
Added: branches/sound2/src/orxonox/sound/SoundMainMenu.h
===================================================================
--- branches/sound2/src/orxonox/sound/SoundMainMenu.h (rev 0)
+++ branches/sound2/src/orxonox/sound/SoundMainMenu.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -0,0 +1,50 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Erwin 'vaiursch' Herrsche
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _SOUNDMAINMENU_H__
+#define _SOUNDMAINMENU_H__
+
+#include <string>
+
+#include "core/OrxonoxClass.h"
+#include "OrxonoxPrereqs.h"
+#include "SoundBase.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport SoundMainMenu : public SoundBase, public virtual OrxonoxClass
+ {
+ public:
+ SoundMainMenu();
+ void setConfigValues();
+
+ private:
+ std::string filename_;
+ };
+}
+#endif
Modified: branches/sound2/src/orxonox/sound/SoundManager.cc
===================================================================
--- branches/sound2/src/orxonox/sound/SoundManager.cc 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/sound/SoundManager.cc 2009-05-25 11:53:13 UTC (rev 3055)
@@ -51,8 +51,8 @@
}
else
{
- COUT(4) << "Sound: OpenAL ALUT version:" << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
- COUT(4) << "Sound: OpenAL ALUT supported MIME types:" << alutGetMIMETypes(ALUT_LOADER_BUFFER) << std::endl;
+ COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
+ COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << alutGetMIMETypes(ALUT_LOADER_BUFFER) << std::endl;
if(SoundManager::device_s == NULL)
{
COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
@@ -76,7 +76,7 @@
else
{
if(alcMakeContextCurrent(this->context_) == AL_TRUE)
- COUT(3) << "Sound: OpenAL: Context " << this->context_ << "loaded" << std::endl;
+ COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl;
}
}
}
@@ -123,6 +123,9 @@
*/
void SoundManager::tick(float dt)
{
+ if (!CameraManager::getInstancePtr())
+ return;
+
// update listener position
Camera* camera = CameraManager::getInstance().getActiveCamera();
if(camera == NULL) return;
Modified: branches/sound2/src/orxonox/sound/SoundManager.h
===================================================================
--- branches/sound2/src/orxonox/sound/SoundManager.h 2009-05-25 10:37:19 UTC (rev 3054)
+++ branches/sound2/src/orxonox/sound/SoundManager.h 2009-05-25 11:53:13 UTC (rev 3055)
@@ -30,12 +30,11 @@
#include <AL/al.h>
#include <AL/alc.h>
-#include <orxonox/objects/Tickable.h>
+#include "OrxonoxPrereqs.h"
+#include "orxonox/objects/Tickable.h"
namespace orxonox
{
- class SoundBase;
-
/**
* The SoundManager class manages the OpenAL device, context and listener
* position. It has a list of all SoundBase objects and calls their update
More information about the Orxonox-commit
mailing list