PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: SCSound.h * 00003 * 00004 * Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/) 00005 * 00006 * This file is part of PixelLight. 00007 * 00008 * PixelLight is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU Lesser General Public License as published by 00010 * the Free Software Foundation, either version 3 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * PixelLight is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public License 00019 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00020 \*********************************************************/ 00021 00022 00023 #ifndef __PLSOUND_SCENENODES_SCSOUND_H__ 00024 #define __PLSOUND_SCENENODES_SCSOUND_H__ 00025 #pragma once 00026 00027 00028 //[-------------------------------------------------------] 00029 //[ Includes ] 00030 //[-------------------------------------------------------] 00031 #include <PLScene/Scene/SceneContainer.h> 00032 #include <PLScene/Scene/SceneNodeHandler.h> 00033 #include "PLSound/PLSound.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Namespace ] 00038 //[-------------------------------------------------------] 00039 namespace PLSound { 00040 00041 00042 //[-------------------------------------------------------] 00043 //[ Forward declarations ] 00044 //[-------------------------------------------------------] 00045 class SoundManager; 00046 00047 00048 //[-------------------------------------------------------] 00049 //[ Classes ] 00050 //[-------------------------------------------------------] 00051 /** 00052 * @brief 00053 * Sound scene node container 00054 */ 00055 class SCSound : public PLScene::SceneContainer { 00056 00057 00058 //[-------------------------------------------------------] 00059 //[ RTTI interface ] 00060 //[-------------------------------------------------------] 00061 pl_class(PLSOUND_RTTI_EXPORT, SCSound, "PLSound", PLScene::SceneContainer, "Sound scene node container") 00062 // Attributes 00063 #ifdef ANDROID 00064 // [TODO] Make PLSoundOpenSLES to the default (because it's open and free) as soon as it's implemented 00065 pl_attribute(SoundAPI, PLCore::String, "PLSoundFMODEx::SoundManager", ReadWrite, DirectValue, "Name of the sound API this scene container is using", "") 00066 // pl_attribute(SoundAPI, PLCore::String, "PLSoundOpenSLES::SoundManager", ReadWrite, DirectValue, "Name of the sound API this scene container is using", "") 00067 #else 00068 pl_attribute(SoundAPI, PLCore::String, "PLSoundOpenAL::SoundManager", ReadWrite, DirectValue, "Name of the sound API this scene container is using", "") 00069 #endif 00070 pl_attribute(Volume, float, 1.0f, ReadWrite, GetSet, "Volume (value from 0.0-1.0 -> 0.0 = silence, 1.0 = full volume)", "Min='0.0' Max='1.0'") 00071 pl_attribute(Pitch, float, 1.0f, ReadWrite, GetSet, "Pitch multiplier (pitch<1.0=slower/pitch=1.0=normal/pitch>1.0=faster)", "Min='0.0'") 00072 pl_attribute(Listener, PLCore::String, "", ReadWrite, GetSet, "Name of the scene node used as listener", "") 00073 // Constructors 00074 pl_constructor_0(DefaultConstructor, "Default constructor", "") 00075 // Slots 00076 pl_slot_0(OnUpdate, "Called when the scene node needs to be updated", "") 00077 pl_class_end 00078 00079 00080 //[-------------------------------------------------------] 00081 //[ Public RTTI get/set functions ] 00082 //[-------------------------------------------------------] 00083 public: 00084 PLSOUND_API float GetVolume() const; 00085 PLSOUND_API void SetVolume(float fValue); 00086 PLSOUND_API float GetPitch() const; 00087 PLSOUND_API void SetPitch(float fValue); 00088 PLSOUND_API PLCore::String GetListener() const; 00089 PLSOUND_API void SetListener(const PLCore::String &sValue); 00090 00091 00092 //[-------------------------------------------------------] 00093 //[ Public functions ] 00094 //[-------------------------------------------------------] 00095 public: 00096 /** 00097 * @brief 00098 * Default constructor 00099 */ 00100 PLSOUND_API SCSound(); 00101 00102 /** 00103 * @brief 00104 * Destructor 00105 */ 00106 PLSOUND_API virtual ~SCSound(); 00107 00108 /** 00109 * @brief 00110 * Returns the PL sound manager 00111 * 00112 * @return 00113 * The PL sound manager, a null pointer on error (if that's the case, something went totally wrong :) 00114 */ 00115 PLSOUND_API SoundManager *GetSoundManager() const; 00116 00117 00118 //[-------------------------------------------------------] 00119 //[ Private functions ] 00120 //[-------------------------------------------------------] 00121 private: 00122 /** 00123 * @brief 00124 * Called when the scene node needs to be updated 00125 */ 00126 void OnUpdate(); 00127 00128 00129 //[-------------------------------------------------------] 00130 //[ Private data ] 00131 //[-------------------------------------------------------] 00132 private: 00133 float m_fVolume; /**< Volume (value from 0.0-1.0 -> 0.0 = silence, 1.0 = full volume) */ 00134 float m_fPitch; /**< Pitch multiplier (pitch<1.0=slower/pitch=1.0=normal/pitch>1.0=faster) */ 00135 PLCore::String m_sListener; /**< Name of the scene node used as listener */ 00136 SoundManager *m_pSoundManager; /**< The PL sound manager, can be a null pointer */ 00137 PLScene::SceneNodeHandler m_cListenerNodeHandler; /**< Listener scene node handler */ 00138 00139 00140 //[-------------------------------------------------------] 00141 //[ Protected virtual PLScene::SceneNode functions ] 00142 //[-------------------------------------------------------] 00143 protected: 00144 PLSOUND_API virtual void InitFunction() override; 00145 PLSOUND_API virtual void OnActivate(bool bActivate) override; 00146 00147 00148 }; 00149 00150 00151 //[-------------------------------------------------------] 00152 //[ Namespace ] 00153 //[-------------------------------------------------------] 00154 } // PLSound 00155 00156 00157 #endif // __PLSOUND_SCENENODES_SCSOUND_H__
|