[Orxonox-commit 1178] r5899 - in code/branches/core5: data/levels src/orxonox/gamestates src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Oct 7 11:19:20 CEST 2009
Author: rgrieder
Date: 2009-10-07 11:19:19 +0200 (Wed, 07 Oct 2009)
New Revision: 5899
Modified:
code/branches/core5/data/levels/presentation_pong.oxw
code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc
code/branches/core5/src/orxonox/sound/AmbientSound.cc
code/branches/core5/src/orxonox/sound/BaseSound.cc
code/branches/core5/src/orxonox/sound/BaseSound.h
code/branches/core5/src/orxonox/sound/WorldSound.cc
Log:
Renaming BaseSound::setSoundFile (and all its associates) to setSource to be compliant with classes like ParicleInterface.
Modified: code/branches/core5/data/levels/presentation_pong.oxw
===================================================================
--- code/branches/core5/data/levels/presentation_pong.oxw 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/data/levels/presentation_pong.oxw 2009-10-07 09:19:19 UTC (rev 5899)
@@ -45,7 +45,7 @@
description = "A simple testlevel"
gametype = Pong
>
- <AmbientSound soundFile="ambient/mainmenu.wav" playOnLoad=true />
+ <AmbientSound source="ambient/mainmenu.wav" playOnLoad=true />
<Scene
ambientlight = "0.5, 0.5, 0.5"
@@ -84,7 +84,7 @@
<ParticleSpawner name=scoreeffect_left position="-120,0,-30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
<ParticleSpawner name=scoreeffect_left position="-120,0,-45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
- <WorldSound name="scoreSound" position="0,0,0" soundFile="sounds/pong_score.wav" >
+ <WorldSound name="scoreSound" position="0,0,0" source="sounds/pong_score.wav" >
<events>
<play>
<EventListener event=pongcenter />
Modified: code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/src/orxonox/gamestates/GSMainMenu.cc 2009-10-07 09:19:19 UTC (rev 5899)
@@ -62,7 +62,7 @@
{
// Load sound
this->ambient_ = new AmbientSound(0);
- this->ambient_->setSoundFile("ambient/mainmenu.wav");
+ this->ambient_->setSource("ambient/mainmenu.wav");
}
}
Modified: code/branches/core5/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/branches/core5/src/orxonox/sound/AmbientSound.cc 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/src/orxonox/sound/AmbientSound.cc 2009-10-07 09:19:19 UTC (rev 5899)
@@ -48,7 +48,7 @@
void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(AmbientSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "soundFile", setSoundFile, getSoundFile, xmlelement, mode);
+ XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
}
Modified: code/branches/core5/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/core5/src/orxonox/sound/BaseSound.cc 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/src/orxonox/sound/BaseSound.cc 2009-10-07 09:19:19 UTC (rev 5899)
@@ -39,8 +39,8 @@
namespace orxonox
{
BaseSound::BaseSound()
- : source_(0)
- , buffer_(0)
+ : audioSource_(0)
+ , audioBuffer_(0)
, bPlayOnLoad_(false)
, bLoop_(false)
{
@@ -49,55 +49,55 @@
BaseSound::~BaseSound()
{
- this->setSoundFile("");
+ this->setSource("");
}
void BaseSound::play()
{
- if (alIsSource(this->source_))
+ if (alIsSource(this->audioSource_))
{
if (this->bLoop_)
- alSourcei(this->source_, AL_LOOPING, AL_TRUE);
+ alSourcei(this->audioSource_, AL_LOOPING, AL_TRUE);
else
- alSourcei(this->source_, AL_LOOPING, AL_FALSE);
- alSourcePlay(this->source_);
+ alSourcei(this->audioSource_, AL_LOOPING, AL_FALSE);
+ alSourcePlay(this->audioSource_);
if (alGetError() != AL_NO_ERROR)
{
- COUT(2) << "Sound: OpenAL: Error playin sound " << this->source_ << std::endl;
+ COUT(2) << "Sound: OpenAL: Error playin sound " << this->audioSource_ << std::endl;
}
}
}
void BaseSound::stop()
{
- if (alIsSource(this->source_))
- alSourceStop(this->source_);
+ if (alIsSource(this->audioSource_))
+ alSourceStop(this->audioSource_);
}
void BaseSound::pause()
{
- if (alIsSource(this->source_))
- alSourcePause(this->source_);
+ if (alIsSource(this->audioSource_))
+ alSourcePause(this->audioSource_);
}
bool BaseSound::isPlaying()
{
- if (alIsSource(this->source_))
+ if (alIsSource(this->audioSource_))
return getSourceState() == AL_PLAYING;
return false;
}
bool BaseSound::isPaused()
{
- if (alIsSource(this->source_))
+ if (alIsSource(this->audioSource_))
return getSourceState() == AL_PAUSED;
return true;
}
bool BaseSound::isStopped()
{
- if (alIsSource(this->source_))
+ if (alIsSource(this->audioSource_))
return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED;
return true;
}
@@ -108,63 +108,63 @@
this->play();
}
- void BaseSound::setSoundFile(const std::string& soundFile)
+ void BaseSound::setSource(const std::string& source)
{
- this->soundFile_ = soundFile;
+ this->source_ = source;
if (!GameMode::playsSound())
return;
- if (soundFile.empty() && alIsSource(this->source_))
+ if (source.empty() && alIsSource(this->audioSource_))
{
// Unload sound
- alSourcei(this->source_, AL_BUFFER, 0);
- alDeleteSources(1, &this->source_);
- alDeleteBuffers(1, &this->buffer_);
+ alSourcei(this->audioSource_, AL_BUFFER, 0);
+ alDeleteSources(1, &this->audioSource_);
+ alDeleteBuffers(1, &this->audioBuffer_);
return;
}
- COUT(3) << "Sound: OpenAL ALUT: loading file " << soundFile << std::endl;
+ COUT(3) << "Sound: OpenAL ALUT: loading file " << source << std::endl;
// Get DataStream from the resources
- shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(soundFile);
+ shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(source);
if (fileInfo == NULL)
{
- COUT(2) << "Warning: Sound file '" << soundFile << "' not found" << std::endl;
+ COUT(2) << "Warning: Sound file '" << source << "' not found" << std::endl;
return;
}
- DataStreamPtr stream = Resource::open(soundFile);
+ DataStreamPtr stream = Resource::open(source);
// Read everything into a temporary buffer
char* buffer = new char[fileInfo->size];
stream->read(buffer, fileInfo->size);
- this->buffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
+ this->audioBuffer_ = alutCreateBufferFromFileImage(buffer, fileInfo->size);
delete[] buffer;
- if (this->buffer_ == AL_NONE)
+ if (this->audioBuffer_ == AL_NONE)
{
COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
return;
//if (filename.find("ogg", 0) != std::string::npos)
//{
// COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
- // this->buffer_ = loadOggFile(filename);
+ // this->audioBuffer_ = loadOggFile(filename);
//}
- //if (this->buffer_ == AL_NONE)
+ //if (this->audioBuffer_ == AL_NONE)
//{
// COUT(2) << "Sound: fallback ogg loader failed: " << alutGetErrorString(alutGetError()) << std::endl;
// return;
//}
}
- alGenSources(1, &this->source_);
- alSourcei(this->source_, AL_BUFFER, this->buffer_);
+ alGenSources(1, &this->audioSource_);
+ alSourcei(this->audioSource_, AL_BUFFER, this->audioBuffer_);
if (alGetError() != AL_NO_ERROR)
{
- COUT(2) << "Sound: OpenAL: Error loading sample file: " << soundFile << std::endl;
+ COUT(2) << "Sound: OpenAL: Error loading sample file: " << source << std::endl;
return;
}
- alSource3f(this->source_, AL_POSITION, 0, 0, 0);
+ alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0);
if (this->bPlayOnLoad_)
this->play();
@@ -173,7 +173,7 @@
ALint BaseSound::getSourceState()
{
ALint state;
- alGetSourcei(this->source_, AL_SOURCE_STATE, &state);
+ alGetSourcei(this->audioSource_, AL_SOURCE_STATE, &state);
return state;
}
Modified: code/branches/core5/src/orxonox/sound/BaseSound.h
===================================================================
--- code/branches/core5/src/orxonox/sound/BaseSound.h 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/src/orxonox/sound/BaseSound.h 2009-10-07 09:19:19 UTC (rev 5899)
@@ -54,8 +54,8 @@
bool isPaused();
bool isStopped();
- void setSoundFile(const std::string& soundFile);
- const std::string& getSoundFile() { return this->soundFile_; }
+ void setSource(const std::string& source);
+ const std::string& getSource() { return this->source_; }
bool getPlayOnLoad() { return this->bPlayOnLoad_; }
void setPlayOnLoad(bool val);
@@ -64,14 +64,14 @@
void setLoop(bool val) { this->bLoop_ = val; }
protected:
- //ALuint loadOggFile(const std::string& filename);
+ ALuint loadOggFile(const std::string& filename);
ALint getSourceState();
- ALuint source_;
- ALuint buffer_;
+ ALuint audioSource_;
+ ALuint audioBuffer_;
private:
- std::string soundFile_;
+ std::string source_;
bool bPlayOnLoad_;
bool bLoop_;
};
Modified: code/branches/core5/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/branches/core5/src/orxonox/sound/WorldSound.cc 2009-10-07 00:02:15 UTC (rev 5898)
+++ code/branches/core5/src/orxonox/sound/WorldSound.cc 2009-10-07 09:19:19 UTC (rev 5899)
@@ -51,7 +51,7 @@
void WorldSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(WorldSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "soundFile", setSoundFile, getSoundFile, xmlelement, mode);
+ XMLPortParamExtern(WorldSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
XMLPortParamExtern(WorldSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
XMLPortParamExtern(WorldSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
}
@@ -64,23 +64,23 @@
void WorldSound::tick(float dt)
{
- if (alIsSource(this->source_))
+ if (alIsSource(this->audioSource_))
{
const Vector3& pos = this->getWorldPosition();
- alSource3f(this->source_, AL_POSITION, pos.x, pos.y, pos.z);
+ alSource3f(this->audioSource_, AL_POSITION, pos.x, pos.y, pos.z);
ALenum error = alGetError();
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl;
const Vector3& vel = this->getVelocity();
- alSource3f(this->source_, AL_VELOCITY, vel.x, vel.y, vel.z);
+ alSource3f(this->audioSource_, AL_VELOCITY, vel.x, vel.y, vel.z);
error = alGetError();
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
const Quaternion& orient = this->getWorldOrientation();
Vector3 at = orient.zAxis();
- alSource3f(this->source_, AL_DIRECTION, at.x, at.y, at.z);
+ alSource3f(this->audioSource_, AL_DIRECTION, at.x, at.y, at.z);
error = alGetError();
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
More information about the Orxonox-commit
mailing list