diff --git a/src/modules/sound/snddefault/OpenalSound.cpp b/src/modules/sound/snddefault/OpenalSound.cpp index 7e3ace6d4..799e32e8d 100644 --- a/src/modules/sound/snddefault/OpenalSound.cpp +++ b/src/modules/sound/snddefault/OpenalSound.cpp @@ -26,23 +26,9 @@ OpenalSound::OpenalSound(const char* filename, OpenalSoundInterface* sitf, int flags, bool loop, bool static_pool) : Sound(flags, loop) +, static_pool(static_pool) +, itf(sitf) { - this->static_pool = static_pool; - poolindex = -1; - itf = sitf; - - MAX_DISTANCE = 10000.0f; - MAX_DISTANCE_LOW = 5.0f; - REFERENCE_DISTANCE = 5.0f; - ROLLOFF_FACTOR = 0.5f; - - int i; - for (i = 0; i<3; i++) { - source_position[i] = 0.0f; - source_velocity[i] = 0.0f; - zeroes[i] = 0.0f; - } - GfLogTrace("OpenAL : Creating %s source from %s\n", static_pool ? "static" : "dynamic", filename); diff --git a/src/modules/sound/snddefault/OpenalSound.h b/src/modules/sound/snddefault/OpenalSound.h index 570cfd9e6..c0d2b29ec 100644 --- a/src/modules/sound/snddefault/OpenalSound.h +++ b/src/modules/sound/snddefault/OpenalSound.h @@ -34,21 +34,21 @@ class OpenalSoundInterface; class OpenalSound : public Sound { protected: - ALuint buffer; ///< buffer id - ALuint source; ///< source id - ALfloat source_position[3]; ///< source position - ALfloat source_velocity[3]; ///< source velocity - ALfloat zeroes[3]; ///< just a vector of 0s + ALuint buffer = 0; ///< buffer id + ALuint source = 0; ///< source id + ALfloat source_position[3] = { 0.0f, 0.0f, 0.0f }; ///< source position + ALfloat source_velocity[3] = { 0.0f, 0.0f, 0.0f }; ///< source velocity + const ALfloat zeroes[3] = { 0.0f, 0.0f, 0.0f }; ///< just a vector of 0s ALfloat back[6]; ///< direction of back ALfloat front[6]; ///< direction of front - ALfloat MAX_DISTANCE; ///< maximum allowed distance - ALfloat MAX_DISTANCE_LOW; ///< maximum allowed distance - ALfloat REFERENCE_DISTANCE; ///< reference distance for sound - ALfloat ROLLOFF_FACTOR; ///< how fast we need to roll off - int poolindex; ///< which pool the sound is assigned to - OpenalSoundInterface* itf; ///< Handle to the interface - bool static_pool; ///< dynamic or static source assignment? - bool is_enabled; ///< is it available at all? + ALfloat MAX_DISTANCE = 10000.0f; ///< maximum allowed distance + ALfloat MAX_DISTANCE_LOW = 5.0f; ///< maximum allowed distance + ALfloat REFERENCE_DISTANCE = 5.0f; ///< reference distance for sound + ALfloat ROLLOFF_FACTOR = 0.5f; ///< how fast we need to roll off + int poolindex = -1; ///< which pool the sound is assigned to + OpenalSoundInterface* itf = nullptr; ///< Handle to the interface + bool static_pool = true; ///< dynamic or static source assignment? + bool is_enabled = false; ///< is it available at all? public: OpenalSound(const char* filename, OpenalSoundInterface* sitf, diff --git a/src/modules/sound/snddefault/Sound.cpp b/src/modules/sound/snddefault/Sound.cpp index 81db27f01..c4512ee71 100644 --- a/src/modules/sound/snddefault/Sound.cpp +++ b/src/modules/sound/snddefault/Sound.cpp @@ -23,17 +23,8 @@ /// Construct a sound. -Sound::Sound(int flags, bool loop) +Sound::Sound(int flags, bool loop) : flags(flags), loop(loop) { - iface = nullptr; - this->flags = flags; - MAX_VOL = 1.0f; - volume = 0.0f; - pitch = 1.0f; - lowpass = 1.0f; - this->loop = loop; - playing = false; - paused = false; } /// Destructor diff --git a/src/modules/sound/snddefault/Sound.h b/src/modules/sound/snddefault/Sound.h index a45eb15f4..e0a2ef712 100644 --- a/src/modules/sound/snddefault/Sound.h +++ b/src/modules/sound/snddefault/Sound.h @@ -51,22 +51,22 @@ class Sound { protected: - class SoundInterface* iface; ///< Handler to the interface - int flags; ///< Flags relating to what effects are to be used. - float MAX_VOL; ///< Maximum volume - float volume; ///< Current volume - float pitch; ///< Current pitch - float lowpass; ///< Current low pass filter - bool loop; ///< Whether it's a looping sound - bool playing; ///< Sound is playing - bool paused; ///< sound is paused + class SoundInterface* iface = nullptr; ///< Handler to the interface + int flags = 0; ///< Flags relating to what effects are to be used. + float MAX_VOL = 1.0f; ///< Maximum volume + float volume = 0.0f; ///< Current volume + float pitch = 1.0f; ///< Current pitch + float lowpass = 1.0f; ///< Current low pass filter + bool loop = false; ///< Whether it's a looping sound + bool playing = false; ///< Sound is playing + bool paused = false; ///< sound is paused public: /// Construct a sound. Sound(int flags = (ACTIVE_VOLUME|ACTIVE_PITCH), bool loop = false); - /// Destructor + /// Destructor virtual ~Sound(); virtual void setVolume(float vol); @@ -112,8 +112,8 @@ class SoundSource sgVec3 p_src; ///< source position sgVec3 u_src; ///< source velocity; float a; ///< Environmental attenuation - float f; ///< Environmental frequency shift - float lp; ///< Environmental filtering + float f; ///< Environmental frequency shift + float lp; ///< Environmental filtering SoundSource(); void update(); void setSource(sgVec3 p, sgVec3 u);