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_SCENENODEMODIFIERS_SNMSOUND_H__
00024 #define __PLSOUND_SCENENODEMODIFIERS_SNMSOUND_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include <PLScene/Scene/SceneNodeModifier.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 SNMSound : public PLScene::SceneNodeModifier {
00060
00061
00062
00063
00064
00065 public:
00066
00067
00068
00069
00070 enum EFlags {
00071 Stream = 1<<2,
00072 No3D = 1<<3,
00073 NoLoop = 1<<4,
00074 NoStartPlayback = 1<<5
00075 };
00076 pl_enum(EFlags)
00077 pl_enum_base(PLScene::SceneNodeModifier::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, SNMSound, "PLSound", PLScene::SceneNodeModifier, "Scene node modifier which is able to playback a sound")
00089
00090 pl_attribute(Sound, PLCore::String, "", ReadWrite, GetSet, "Name 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'")
00091 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'")
00092 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'")
00093 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'")
00094 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'")
00095 pl_attribute(RolloffFactor, float, 1.0f, ReadWrite, GetSet, "This will scale the distance attenuation over the applicable range", "Min='0.0'")
00096
00097 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "")
00098
00099 pl_constructor_1(ParameterConstructor, PLScene::SceneNode&, "Parameter constructor", "")
00100
00101 pl_slot_0(OnPosition, "Called when the scene node position changed", "")
00102 pl_class_end
00103
00104
00105
00106
00107
00108 public:
00109 PLSOUND_API PLCore::String GetSound() const;
00110 PLSOUND_API void SetSound(const PLCore::String &sValue);
00111 PLSOUND_API float GetVolume() const;
00112 PLSOUND_API void SetVolume(float fValue);
00113 PLSOUND_API float GetPitch() const;
00114 PLSOUND_API void SetPitch(float fValue);
00115 PLSOUND_API float GetReferenceDistance() const;
00116 PLSOUND_API void SetReferenceDistance(float fValue);
00117 PLSOUND_API float GetMaxDistance() const;
00118 PLSOUND_API void SetMaxDistance(float fValue);
00119 PLSOUND_API float GetRolloffFactor() const;
00120 PLSOUND_API void SetRolloffFactor(float fValue);
00121 PLSOUND_API virtual void SetFlags(PLCore::uint32 nValue) override;
00122
00123
00124
00125
00126
00127 public:
00128
00129
00130
00131
00132
00133
00134
00135 PLSOUND_API SNMSound(PLScene::SceneNode &cSceneNode);
00136
00137
00138
00139
00140
00141 PLSOUND_API virtual ~SNMSound();
00142
00143
00144
00145
00146
00147
00148
00149
00150 PLSOUND_API Source *GetSoundSource() const;
00151
00152
00153
00154
00155
00156 protected:
00157 PLSOUND_API virtual void OnActivate(bool bActivate) override;
00158
00159
00160
00161
00162
00163 protected:
00164 PLCore::String m_sSound;
00165 float m_fVolume;
00166 float m_fPitch;
00167 float m_fReferenceDistance;
00168 float m_fMaxDistance;
00169 float m_fRolloffFactor;
00170
00171
00172
00173
00174
00175 private:
00176
00177
00178
00179
00180
00181
00182
00183 SCSound *GetSoundContainer() const;
00184
00185
00186
00187
00188
00189 void OnPosition();
00190
00191
00192
00193
00194
00195 void Load();
00196
00197
00198
00199
00200
00201 private:
00202 ResourceHandler *m_pSoundSourceHandler;
00203
00204
00205 };
00206
00207
00208
00209
00210
00211 }
00212
00213
00214 #endif // __PLSOUND_SCENENODEMODIFIERS_SNMSOUND_H__