[Orxonox-commit 297] r2932 - branches/sound/src/sound
erwin at orxonox.net
erwin at orxonox.net
Mon Apr 27 15:30:34 CEST 2009
Author: erwin
Date: 2009-04-27 15:30:34 +0200 (Mon, 27 Apr 2009)
New Revision: 2932
Modified:
branches/sound/src/sound/SoundBase.cc
branches/sound/src/sound/SoundBase.h
branches/sound/src/sound/SoundManager.cc
branches/sound/src/sound/SoundManager.h
Log:
Sound: implemented sample file loading via alut
Modified: branches/sound/src/sound/SoundBase.cc
===================================================================
--- branches/sound/src/sound/SoundBase.cc 2009-04-27 12:41:50 UTC (rev 2931)
+++ branches/sound/src/sound/SoundBase.cc 2009-04-27 13:30:34 UTC (rev 2932)
@@ -112,6 +112,22 @@
}
}
+ bool SoundBase::loadFile(std::string filename) {
+ this->buffer_ = alutCreateBufferFromFile(filename.c_str());
+ if(this->buffer_ == AL_NONE) {
+ COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError());
+ return false;
+ }
+
+ alGenSources(1, &this->source_);
+ alSourcei(this->source_, AL_BUFFER, this->buffer_);
+ if(alGetError() != AL_NO_ERROR) {
+ COUT(2) << "OpenAL: Error loading sample file";
+ return false;
+ }
+ return true;
+ }
+
ALint SoundBase::getSourceState() {
ALint state;
alGetSourcei(this->source_, AL_SOURCE_STATE, &state);
Modified: branches/sound/src/sound/SoundBase.h
===================================================================
--- branches/sound/src/sound/SoundBase.h 2009-04-27 12:41:50 UTC (rev 2931)
+++ branches/sound/src/sound/SoundBase.h 2009-04-27 13:30:34 UTC (rev 2932)
@@ -28,7 +28,8 @@
#ifndef _SOUNDBASE_H__
#define _SOUNDBASE_H__
-#include <al.h>
+#include <AL/al.h>
+#include <AL/alut.h>
#include <string>
namespace orxonox
@@ -56,7 +57,7 @@
bool isPaused();
bool isStopped();
- virtual void loadFile(std::string filename) = 0;
+ bool loadFile(std::string filename);
private:
ALuint source_;
Modified: branches/sound/src/sound/SoundManager.cc
===================================================================
--- branches/sound/src/sound/SoundManager.cc 2009-04-27 12:41:50 UTC (rev 2931)
+++ branches/sound/src/sound/SoundManager.cc 2009-04-27 13:30:34 UTC (rev 2932)
@@ -26,7 +26,7 @@
*
*/
-#include <OgreSceneNode.h>
+#include <AL/alut.h>
#include "orxonox/CameraManager.h"
#include "orxonox/objects/worldentities/Camera.h"
@@ -56,17 +56,9 @@
*/
SoundManager::SoundManager()
{
- // OpenAL device and context creation
- this->device_ = alcOpenDevice(NULL); // we operate on the default sound device
- if(this->device_)
- COUT(2) << "OpenAL: Could not create sound device, there will be no sound!" << std::endl;
-
- this->context_ = alcCreateContext(this->device_, NULL);
- alcMakeContextCurrent(this->context_);
- ALenum error = alcGetError(this->device_);
- if(error != ALC_NO_ERROR)
- COUT(2) << "OpenAL: Could not create sound context." << std::endl;
-
+ if(!alutInit(NULL,NULL)) {
+ COUT(2) << "OpenAL ALUT: " << alutGetErrorString(alutGetError());
+ }
}
/**
Modified: branches/sound/src/sound/SoundManager.h
===================================================================
--- branches/sound/src/sound/SoundManager.h 2009-04-27 12:41:50 UTC (rev 2931)
+++ branches/sound/src/sound/SoundManager.h 2009-04-27 13:30:34 UTC (rev 2932)
@@ -27,8 +27,8 @@
#ifndef _SOUNDMANGER_H__
#define _SOUNDMANGER_H__
-#include <al.h>
-#include <alc.h>
+#include <AL/al.h>
+#include <AL/alc.h>
#include <orxonox/objects/Tickable.h>
@@ -56,9 +56,6 @@
SoundManager(); // private constructor -> singleton
static SoundManager* singleton_;
- ALCcontext* context_;
- ALCdevice* device_;
-
std::list<SoundBase*> soundlist_;
}; // class SoundManager
More information about the Orxonox-commit
mailing list