[Orxonox-commit 1652] r6370 - in code/branches/presentation2: data/gui/scripts src/orxonox src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Thu Dec 17 11:10:40 CET 2009
Author: rgrieder
Date: 2009-12-17 11:10:39 +0100 (Thu, 17 Dec 2009)
New Revision: 6370
Modified:
code/branches/presentation2/data/gui/scripts/AudioMenu.lua
code/branches/presentation2/src/orxonox/MoodManager.cc
code/branches/presentation2/src/orxonox/MoodManager.h
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
code/branches/presentation2/src/orxonox/sound/AmbientSound.h
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
code/branches/presentation2/src/orxonox/sound/BaseSound.h
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
code/branches/presentation2/src/orxonox/sound/SoundManager.h
code/branches/presentation2/src/orxonox/sound/WorldSound.cc
code/branches/presentation2/src/orxonox/sound/WorldSound.h
Log:
Little cleanup in sound stuff and MoodManager.
Caution: Renamed SoundTypes to {All, Music, Effects}!
Modified: code/branches/presentation2/data/gui/scripts/AudioMenu.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/AudioMenu.lua 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/data/gui/scripts/AudioMenu.lua 2009-12-17 10:10:39 UTC (rev 6370)
@@ -17,12 +17,12 @@
masterscrollbar_active = false
musicscrollbar_active = false
effectsscrollbar_active = false
- mastervolume = soundMgr:getVolume(orxonox.SoundType.none)
- musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient)
- effectsvolume = soundMgr:getVolume(orxonox.SoundType.effects)
- mastermute = soundMgr:getMute(orxonox.SoundType.none)
- musicmute = soundMgr:getMute(orxonox.SoundType.ambient)
- effectsmute = soundMgr:getMute(orxonox.SoundType.effects)
+ mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
+ musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
+ effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
+ mastermute = soundMgr:getMute(orxonox.SoundType.All)
+ musicmute = soundMgr:getMute(orxonox.SoundType.Music)
+ effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
@@ -130,7 +130,7 @@
mastermute = true
end
end
- soundMgr:toggleMute(orxonox.SoundType.none)
+ soundMgr:toggleMute(orxonox.SoundType.All)
end
function P.AudioMuteMusicCheckbox_clicked(e)
@@ -145,7 +145,7 @@
musicmute = true
end
end
- soundMgr:toggleMute(orxonox.SoundType.ambient)
+ soundMgr:toggleMute(orxonox.SoundType.Music)
end
function P.AudioMuteEffectsCheckbox_clicked(e)
@@ -160,7 +160,7 @@
effectsmute = true
end
end
- soundMgr:toggleMute(orxonox.SoundType.effects)
+ soundMgr:toggleMute(orxonox.SoundType.Effects)
end
function P.AudioThemeListbox_changed(e)
Modified: code/branches/presentation2/src/orxonox/MoodManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/MoodManager.cc 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/MoodManager.cc 2009-12-17 10:10:39 UTC (rev 6370)
@@ -40,7 +40,6 @@
MoodManager::MoodManager()
{
RegisterRootObject(MoodManager);
- moodOld_ = "default";
this->setConfigValues();
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&MoodManager::setMood, this), "setMood"));
}
@@ -56,16 +55,16 @@
.callback(this, &MoodManager::checkMoodValidity);
}
- /**
- * Sets the mood
- * @note TODO: Inform dependent classes of mood change
- */
+ /** Sets the mood
+ @note
+ TODO: Inform dependent classes of mood change
+ */
void MoodManager::setMood(const std::string& mood)
{
ModifyConfigValue(mood_, set, mood);
}
- // gets the current mood
+ //! Gets the current mood
const std::string& MoodManager::getMood()
{
return mood_;
@@ -73,11 +72,8 @@
void MoodManager::checkMoodValidity()
{
- if(mood_ != "default" && mood_ != "dnb") // Insert new moods here
- {
+ if (mood_ != "default" && mood_ != "dnb") // Insert new moods here; TODO: make this generic
ResetConfigValue(mood_);
- }
- COUT(3) << "MoodManager: Mood now set to " << mood_ << std::endl;
- return;
+ COUT(4) << "MoodManager: Mood set to " << mood_ << std::endl;
}
}
Modified: code/branches/presentation2/src/orxonox/MoodManager.h
===================================================================
--- code/branches/presentation2/src/orxonox/MoodManager.h 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/MoodManager.h 2009-12-17 10:10:39 UTC (rev 6370)
@@ -58,13 +58,12 @@
static MoodManager& getInstance() { return Singleton<MoodManager>::getInstance(); } // tolua_export
private:
+ void checkMoodValidity();
// config values
std::string mood_;
std::string moodOld_;
- void checkMoodValidity();
-
static MoodManager* singletonPtr_s;
}; // tolua_export
} // tolua_export
Modified: code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/AmbientSound.cc 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/AmbientSound.cc 2009-12-17 10:10:39 UTC (rev 6370)
@@ -66,9 +66,9 @@
void AmbientSound::registerVariables()
{
registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged));
- registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::loopingChanged));
- registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::pitchChanged));
- registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::stateChanged));
+ registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
+ registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
+ registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::stateChanged));
}
void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -124,10 +124,10 @@
BaseSound::pause();
}
- float AmbientSound::getVolumeGain()
+ float AmbientSound::getRealVolume()
{
assert(GameMode::playsSound());
- return SoundManager::getInstance().getVolume(SoundType::ambient);
+ return SoundManager::getInstance().getRealVolume(SoundType::Music);
}
void AmbientSound::doPause()
Modified: code/branches/presentation2/src/orxonox/sound/AmbientSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/AmbientSound.h 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/AmbientSound.h 2009-12-17 10:10:39 UTC (rev 6370)
@@ -58,8 +58,6 @@
void play();
void stop();
void pause();
-
- float getVolumeGain();
void setAmbientSource(const std::string& source);
const std::string& getAmbientSource() const { return this->ambientSource_; }
@@ -70,8 +68,8 @@
void doPlay();
void doStop();
void doPause();
-
void registerVariables();
+ float getRealVolume();
std::string ambientSource_; //!< Analogous to source_, but mood independent
};
Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-12-17 10:10:39 UTC (rev 6370)
@@ -144,28 +144,17 @@
void BaseSound::setVolume(float vol)
{
- if (vol > 1 || vol < 0)
- {
- COUT(2) << "Sound warning: volume out of range, cropping value." << std::endl;
- vol = vol > 1 ? 1 : vol;
- vol = vol < 0 ? 0 : vol;
- }
- this->volume_ = vol;
-
+ this->volume_ = clamp(vol, 0.0f, 1.0f);
+ if (this->volume_ != vol)
+ COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
this->updateVolume();
}
- float BaseSound::getVolumeGain()
+ void BaseSound::updateVolume()
{
- assert(GameMode::playsSound());
- return SoundManager::getInstance().getVolume(SoundType::none);
- }
-
- void BaseSound::updateVolume(void)
- {
if (alIsSource(this->audioSource_))
{
- float volume = this->volume_ * this->getVolumeGain();
+ float volume = this->volume_ * this->getRealVolume();
alSourcef(this->audioSource_, AL_GAIN, volume);
if (int error = alGetError())
COUT(2) << "Sound: Error setting volume to " << volume
Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.h 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.h 2009-12-17 10:10:39 UTC (rev 6370)
@@ -66,28 +66,22 @@
{ val ? this->play() : this->stop(); }
virtual void setSource(const std::string& source);
- virtual const std::string& getSource() const { return this->source_; }
- inline void sourceChanged(){ this->setSource(this->source_); }
+ virtual const std::string& getSource() const
+ { return this->source_; }
void setVolume(float vol);
- float getVolume() const { return this->volume_; }
- inline void volumeChanged(){ this->setVolume(this->volume_); }
-
- virtual float getVolumeGain();
- void updateVolume(void);
+ float getVolume() const
+ { return this->volume_; }
+ void updateVolume();
- bool getLooping() const { return this->bLooping_; }
+ bool getLooping() const
+ { return this->bLooping_; }
void setLooping(bool val);
- inline void loopingChanged(){ this->setLooping(this->bLooping_); }
- float getPitch() const { return this->pitch_; }
+ float getPitch() const
+ { return this->pitch_; }
void setPitch(float pitch);
- inline void pitchChanged(){ this->setPitch(this->pitch_); }
-
- void stateChanged();
- //ALuint getALAudioSource(void);
-
protected:
enum State
{
@@ -95,9 +89,23 @@
Playing,
Paused
};
+
+ // network callbacks
+ inline void pitchChanged()
+ { this->setPitch(this->pitch_); }
+ inline void loopingChanged()
+ { this->setLooping(this->bLooping_); }
+ inline void volumeChanged()
+ { this->setVolume(this->volume_); }
+ inline void sourceChanged()
+ { this->setSource(this->source_); }
+ void stateChanged();
+
virtual void initialiseSource();
ALint getSourceState() const;
+ virtual float getRealVolume() = 0;
+
ALuint audioSource_;
bool bPooling_;
shared_ptr<SoundBuffer> soundBuffer_;
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-12-17 10:10:39 UTC (rev 6370)
@@ -50,6 +50,20 @@
{
ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
+ std::string SoundManager::getALErrorString(ALenum code)
+ {
+ switch (code)
+ {
+ case AL_NO_ERROR: return "No error";
+ case AL_INVALID_NAME: return "Invalid AL parameter name";
+ case AL_INVALID_ENUM: return "Invalid AL enum";
+ case AL_INVALID_VALUE: return "Invalid AL value";
+ case AL_INVALID_OPERATION: return "Invalid AL operation";
+ case AL_OUT_OF_MEMORY: return "AL reports out of memory";
+ default: return "Unknown AL error";
+ }
+ }
+
SoundManager::SoundManager()
: effectsPoolSize_(0)
{
@@ -113,13 +127,9 @@
else
COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
- this->setVolumeInternal(1.0, SoundType::none);
- this->setVolumeInternal(1.0, SoundType::ambient);
- this->setVolumeInternal(1.0, SoundType::effects);
-
- this->mute_[SoundType::none] = false;
- this->mute_[SoundType::ambient] = false;
- this->mute_[SoundType::effects] = false;
+ this->mute_[SoundType::All] = 1.0f;
+ this->mute_[SoundType::Music] = 1.0f;
+ this->mute_[SoundType::Effects] = 1.0f;
this->setConfigValues();
@@ -185,15 +195,13 @@
.description("Determines how fast sounds should fade, per second.")
.callback(this, &SoundManager::checkFadeStepValidity);
- SetConfigValue(soundVolume_, 1.0f)
+ SetConfigValueAlias(volume_[SoundType::All], "soundVolume_", 1.0f)
.description("Defines the overall volume.")
.callback(this, &SoundManager::checkSoundVolumeValidity);
-
- SetConfigValue(ambientVolume_, 1.0f)
+ SetConfigValueAlias(volume_[SoundType::Music], "ambientVolume_", 1.0f)
.description("Defines the ambient volume.")
.callback(this, &SoundManager::checkAmbientVolumeValidity);
-
- SetConfigValue(effectsVolume_, 1.0f)
+ SetConfigValueAlias(volume_[SoundType::Effects], "effectsVolume_", 1.0f)
.description("Defines the effects volume.")
.callback(this, &SoundManager::checkEffectsVolumeValidity);
@@ -201,70 +209,81 @@
.description("Maximum number of sources to be made available");
}
- std::string SoundManager::getALErrorString(ALenum code)
- {
- switch (code)
- {
- case AL_NO_ERROR: return "No error";
- case AL_INVALID_NAME: return "Invalid AL parameter name";
- case AL_INVALID_ENUM: return "Invalid AL enum";
- case AL_INVALID_VALUE: return "Invalid AL value";
- case AL_INVALID_OPERATION: return "Invalid AL operation";
- case AL_OUT_OF_MEMORY: return "AL reports out of memory";
- default: return "Unknown AL error";
- }
- }
-
void SoundManager::checkFadeStepValidity()
{
if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
{
- COUT(2) << "Sound warning: Sound step out of range, ignoring change." << std::endl;
+ COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
ResetConfigValue(crossFadeStep_);
}
- COUT(3) << "SoundManager: fade step set to " << crossFadeStep_ << std::endl;
- return;
}
-
- bool SoundManager::checkVolumeValidity(SoundType::Value type)
+
+ void SoundManager::checkVolumeValidity(SoundType::Value type)
{
- bool valid = true;
-
- if(this->getVolumeInternal(type) < 0.0 || this->getVolumeInternal(type) > 1.0)
- {
- COUT(2) << "Sound warning: Sound volume out of range, ignoring change." << std::endl;
- valid = false;
- }
-
+ float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
+ if (clampedVolume != this->volume_[type])
+ COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
this->updateVolume(type);
- COUT(4) << "SoundManager: volume set to " << this->getVolumeInternal(type) << std::endl;
- return valid;
}
-
- void SoundManager::checkSoundVolumeValidity()
+
+ void SoundManager::setVolume(float vol, SoundType::Value type)
{
- if(!checkVolumeValidity(SoundType::none))
- {
- ResetConfigValue(soundVolume_);
- }
+ if (type < 0 || type > SoundType::Effects)
+ return;
+ this->volume_[type] = vol;
+ this->checkVolumeValidity(type);
}
-
- void SoundManager::checkAmbientVolumeValidity()
+
+ float SoundManager::getVolume(SoundType::Value type)
{
- if(!checkVolumeValidity(SoundType::ambient))
- {
- ResetConfigValue(ambientVolume_);
- }
+ if (type < 0 || type > SoundType::Effects)
+ return 0.0f;
+ return this->volume_[type];
}
-
- void SoundManager::checkEffectsVolumeValidity()
+
+ float SoundManager::getRealVolume(SoundType::Value type)
{
- if(!checkVolumeValidity(SoundType::effects))
+ if (type != SoundType::Music && type != SoundType::Effects)
+ return 0.0f;
+ return this->volume_[SoundType::All] * this->mute_[SoundType::All] * this->volume_[type] * this->mute_[type];
+ }
+
+ void SoundManager::updateVolume(SoundType::Value type)
+ {
+ switch(type)
{
- ResetConfigValue(effectsVolume_);
+ case SoundType::All:
+ for (ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ case SoundType::Music:
+ for (ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ case SoundType::Effects:
+ for (ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)
+ (*it)->updateVolume();
+ break;
+ default:
+ assert(false);
}
}
+ void SoundManager::toggleMute(SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return;
+ this->mute_[type] = (this->mute_[type] == 0) ? 1.0f : 0.0f;
+ this->updateVolume(type);
+ }
+
+ bool SoundManager::getMute(SoundType::Value type)
+ {
+ if (type < 0 || type > SoundType::Effects)
+ return true;
+ return (this->mute_[type] == 0);
+ }
+
void SoundManager::setListenerPosition(const Vector3& position)
{
alListener3f(AL_POSITION, position.x, position.y, position.z);
@@ -357,114 +376,6 @@
}
}
}
-
-
- void SoundManager::setVolume(float vol, SoundType::Value type)
- {
- vol = this->checkVolumeRange(vol);
-
- this->setVolumeInternal(vol, type);
-
- this->updateVolume(type);
- }
-
- float SoundManager::checkVolumeRange(float vol)
- {
- if(vol < 0.0 || vol > 1.0)
- {
- COUT(2) << "Sound warning: volume out of range, cropping value." << std::endl;
- vol = vol > 1 ? 1 : vol;
- vol = vol < 0 ? 0 : vol;
- }
-
- return vol;
- }
-
- void SoundManager::updateVolume(SoundType::Value type)
- {
- switch(type)
- {
- case SoundType::none:
- for (ObjectList<BaseSound>::iterator it = ObjectList<BaseSound>::begin(); it != ObjectList<BaseSound>::end(); ++it)
- {
- (*it)->updateVolume();
- }
- break;
- case SoundType::ambient:
- for (ObjectList<AmbientSound>::iterator it = ObjectList<AmbientSound>::begin(); it != ObjectList<AmbientSound>::end(); ++it)
- {
- (*it)->updateVolume();
- }
- break;
- case SoundType::effects:
- for (ObjectList<WorldSound>::iterator it = ObjectList<WorldSound>::begin(); it != ObjectList<WorldSound>::end(); ++it)
- {
- (*it)->updateVolume();
- }
- break;
- default:
- COUT(2) << "Invalid SoundType in SoundManager::updateVolume() - Not updating!" << std::endl;
- }
- }
-
- void SoundManager::setVolumeInternal(float vol, SoundType::Value type)
- {
- switch(type)
- {
- case SoundType::none:
- this->soundVolume_ = vol;
- break;
- case SoundType::ambient:
- this->ambientVolume_ = vol;
- break;
- case SoundType::effects:
- this->effectsVolume_ = vol;
- break;
- default:
- COUT(2) << "Invalid SoundType in SoundManager::setVolumeInternal() - Not setting any volume!" << std::endl;
- }
- }
-
- float SoundManager::getVolumeInternal(SoundType::Value type)
- {
- switch(type)
- {
- case SoundType::none:
- return this->soundVolume_;
- case SoundType::ambient:
- return this->ambientVolume_;
- case SoundType::effects:
- return this->effectsVolume_;
- default:
- COUT(2) << "Invalid SoundType in SoundManager::setVolumeInternal() - Returning 0.0!" << std::endl;
- return 0.0;
- }
- }
-
- float SoundManager::getVolume(SoundType::Value type)
- {
- if(this->mute_[SoundType::none] || this->mute_[type])
- return 0.0;
-
- if(type == SoundType::none)
- return this->getVolumeInternal(type);
-
- return this->getVolumeInternal(SoundType::none)*this->getVolumeInternal(type);
- }
-
- void SoundManager::toggleMute(SoundType::Value type)
- {
- bool mute = !this->mute_[type];
- this->mute_[type] = mute;
-
- this->updateVolume(type);
- }
-
- bool SoundManager::getMute(SoundType::Value type)
- {
- return this->mute_[type];
- }
-
void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound)
{
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-12-17 10:10:39 UTC (rev 6370)
@@ -49,23 +49,19 @@
{
// forward declaration
class SoundBuffer;
-
+
//! Enum for the sound type.
namespace SoundType
{
enum Value
{
- none,
- ambient,
- effects
+ All = 0,
+ Music = 1,
+ Effects = 2
};
}
-
- /**
- * The SoundManager class manages the OpenAL device, context and listener
- * position. It is a singleton.
- *
- */
+
+ //! The SoundManager class manages the OpenAL device, context and listener position.
class _OrxonoxExport SoundManager
// tolua_end
: public Singleton<SoundManager>, public OrxonoxClass
@@ -93,11 +89,14 @@
void unregisterAmbientSound(AmbientSound* oldAmbient);
void pauseAmbientSound(AmbientSound* ambient);
+ // tolua_begin
void setVolume(float vol, SoundType::Value type);
- float getVolume(SoundType::Value type); // tolua_export
+ float getVolume(SoundType::Value type);
+ float getRealVolume(SoundType::Value type);
- void toggleMute(SoundType::Value type); // tolua_export
- bool getMute(SoundType::Value type); // tolua_export
+ void toggleMute(SoundType::Value type);
+ bool getMute(SoundType::Value type);
+ // tolua_end
shared_ptr<SoundBuffer> getSoundBuffer(const std::string& filename);
void releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer);
@@ -113,34 +112,31 @@
void fadeOut(const SmartPtr<AmbientSound>& sound);
void checkFadeStepValidity();
- bool checkVolumeValidity(SoundType::Value type);
- void checkSoundVolumeValidity(void);
- void checkAmbientVolumeValidity(void);
- void checkEffectsVolumeValidity(void);
- float checkVolumeRange(float vol);
-
+ void checkVolumeValidity(SoundType::Value type);
+ void checkSoundVolumeValidity() { this->checkVolumeValidity(SoundType::All); }
+ void checkAmbientVolumeValidity() { this->checkVolumeValidity(SoundType::Music); }
+ void checkEffectsVolumeValidity() { this->checkVolumeValidity(SoundType::Effects); }
void updateVolume(SoundType::Value type);
- void setVolumeInternal(float vol, SoundType::Value type);
- float getVolumeInternal(SoundType::Value type);
-
+ // OpenAL device/context related
std::vector<std::string> deviceNames_;
ALCdevice* device_;
ALCcontext* context_;
+ // Ambient sound related
typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
- AmbientList ambientSounds_;
-
- float crossFadeStep_; //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
+ AmbientList ambientSounds_;
+ //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
+ float crossFadeStep_;
std::list<SmartPtr<AmbientSound> > fadeInList_;
std::list<SmartPtr<AmbientSound> > fadeOutList_;
- float soundVolume_;
- float ambientVolume_;
- float effectsVolume_;
- std::map<SoundType::Value, bool> mute_;
+ // Volume related
+ float volume_[3];
+ float mute_[3];
+ // Sound buffer related
static const unsigned int maxEffectsPoolSize_s = 40 * 1024 * 1024;
unsigned int effectsPoolSize_;
typedef std::list<shared_ptr<SoundBuffer> > EffectsPoolList;
@@ -148,6 +144,7 @@
typedef std::map<std::string, shared_ptr<SoundBuffer> > SoundBufferMap;
SoundBufferMap soundBuffers_;
+ // Sound source related
unsigned int maxSources_;
std::vector<ALuint> soundSources_;
Modified: code/branches/presentation2/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-12-17 10:10:39 UTC (rev 6370)
@@ -56,11 +56,11 @@
void WorldSound::registerVariables()
{
- registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::volumeChanged));
- registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::sourceChanged));
- registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::loopingChanged));
- registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::stateChanged));
- registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::pitchChanged));
+ registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::volumeChanged));
+ registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::sourceChanged));
+ registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::loopingChanged));
+ registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged));
+ registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged));
}
void WorldSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -114,8 +114,8 @@
this->stop();
}
- float WorldSound::getVolumeGain()
+ float WorldSound::getRealVolume()
{
- return SoundManager::getInstance().getVolume(SoundType::effects);
+ return SoundManager::getInstance().getRealVolume(SoundType::Effects);
}
}
Modified: code/branches/presentation2/src/orxonox/sound/WorldSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.h 2009-12-17 09:57:08 UTC (rev 6369)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.h 2009-12-17 10:10:39 UTC (rev 6370)
@@ -45,19 +45,18 @@
{
public:
WorldSound(BaseObject* creator);
- virtual ~WorldSound();
+ ~WorldSound();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void changedActivity();
-
- virtual float getVolumeGain();
+ void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ void changedActivity();
- virtual void tick(float dt);
+ void tick(float dt);
private:
void registerVariables();
void initialiseSource();
+ float getRealVolume();
};
}
More information about the Orxonox-commit
mailing list