00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLSOUND_SCENENODES_SNSOUND_H__
00024 #define __PLSOUND_SCENENODES_SNSOUND_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include <PLScene/Scene/SceneNode.h>
00032 #include "PLSound/PLSound.h"
00033
00034
00035
00036
00037
00038 namespace PLSound {
00039
00040
00041
00042
00043
00044 class Source;
00045 class SCSound;
00046 class ResourceHandler;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 class SNSound : public PLScene::SceneNode {
00060
00061
00062
00063
00064
00065 public:
00066
00067
00068
00069
00070 enum EFlags {
00071 Stream = 1<<10,
00072 No3D = 1<<11,
00073 NoLoop = 1<<12,
00074 NoStartPlayback = 1<<13
00075 };
00076 pl_enum(EFlags)
00077 pl_enum_base(PLScene::SceneNode::EFlags)
00078 pl_enum_value(Stream, "Stream the file (recommended for large files!)")
00079 pl_enum_value(No3D, "No 3D sound")
00080 pl_enum_value(NoLoop, "Do not loop the sound playback")
00081 pl_enum_value(NoStartPlayback, "Do not start sound playback after scene node initialization")
00082 pl_enum_end
00083
00084
00085
00086
00087
00088 pl_class(PLSOUND_RTTI_EXPORT, SNSound, "PLSound", PLScene::SceneNode, "Scene node which is able to playback a sound")
00089
00090 pl_properties
00091 pl_property("Icon", "Data/Textures/IconSound.dds")
00092 pl_properties_end
00093
00094 pl_attribute(Sound, PLCore::String, "", ReadWrite, GetSet, "Filename of the sound which should be played (full path, supported file formats are API dependent). For 3D spatialization, do only use one channel buffers for best compatibility.", "Ext='mp3 ogg wav mid midi it mod s3m xm'")
00095 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'")
00096 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'")
00097 pl_attribute(ReferenceDistance, float, 1.0f, ReadWrite, GetSet, "Used to increase or decrease the range of a source by decreasing or increasing the attenuation, respectively", "Min='0.0'")
00098 pl_attribute(MaxDistance, float, 10000.0f, ReadWrite, GetSet, "Defines a distance beyond which the source will not be further attenuated by distance", "Min='0.0'")
00099 pl_attribute(RolloffFactor, float, 1.0f, ReadWrite, GetSet, "This will scale the distance attenuation over the applicable range", "Min='0.0'")
00100
00101 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "")
00102
00103 pl_constructor_0(DefaultConstructor, "Default constructor", "")
00104
00105 pl_slot_0(OnPosition, "Called when the scene node position changed", "")
00106 pl_class_end
00107
00108
00109
00110
00111
00112 public:
00113 PLSOUND_API PLCore::String GetSound() const;
00114 PLSOUND_API void SetSound(const PLCore::String &sValue);
00115 PLSOUND_API float GetVolume() const;
00116 PLSOUND_API void SetVolume(float fValue);
00117 PLSOUND_API float GetPitch() const;
00118 PLSOUND_API void SetPitch(float fValue);
00119 PLSOUND_API float GetReferenceDistance() const;
00120 PLSOUND_API void SetReferenceDistance(float fValue);
00121 PLSOUND_API float GetMaxDistance() const;
00122 PLSOUND_API void SetMaxDistance(float fValue);
00123 PLSOUND_API float GetRolloffFactor() const;
00124 PLSOUND_API void SetRolloffFactor(float fValue);
00125 PLSOUND_API virtual void SetFlags(PLCore::uint32 nValue) override;
00126
00127
00128
00129
00130
00131 public:
00132
00133
00134
00135
00136 PLSOUND_API SNSound();
00137
00138
00139
00140
00141
00142 PLSOUND_API virtual ~SNSound();
00143
00144
00145
00146
00147
00148
00149
00150
00151 PLSOUND_API Source *GetSoundSource() const;
00152
00153
00154
00155
00156
00157 protected:
00158 PLCore::String m_sSound;
00159 float m_fVolume;
00160 float m_fPitch;
00161 float m_fReferenceDistance;
00162 float m_fMaxDistance;
00163 float m_fRolloffFactor;
00164
00165
00166
00167
00168
00169 private:
00170
00171
00172
00173
00174
00175
00176
00177 SCSound *GetSoundContainer() const;
00178
00179
00180
00181
00182
00183 void Load();
00184
00185
00186
00187
00188
00189 void OnPosition();
00190
00191
00192
00193
00194
00195 private:
00196 ResourceHandler *m_pSoundSourceHandler;
00197
00198
00199
00200
00201
00202 protected:
00203 PLSOUND_API virtual void InitFunction() override;
00204
00205 };
00206
00207
00208
00209
00210
00211 }
00212
00213
00214 #endif // __PLSOUND_SCENENODES_SNSOUND_H__