My Project
ParaScriptingAudio.h
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2007 - 2010 ParaEngine Co., All Rights Reserved.
3 // Date: 2010.6
4 // Description: API for Audio Engine.
5 //-----------------------------------------------------------------------------
6 #pragma once
7 #include "AudioEngine2.h"
8 
9 using namespace std;
10 
11 namespace luabind
12 {
13  namespace adl{
14  class object;
15  }
16  using adl::object;
17 }
18 
19 namespace ParaScripting
20 {
21  using namespace std;
22  using namespace ParaEngine;
23  using namespace luabind;
24 
29  {
30  public:
31  CAudioSource2_ptr m_pAudioSource;
32  public:
33  ParaAudioSource() {};
34  ParaAudioSource(CAudioSource2_ptr& pSource) : m_pAudioSource(pSource) {};
35 
37  bool IsValid() const;
38 
42  void release();
43 
47  bool play();
48 
50  const char* GetName();
51 
56  bool play2d(bool toLoop);
57 
59 
64  bool play3d(float x, float y, float z, float soundstr, bool toLoop);
65 
67  void pause();
68 
70  void stop();
71 
74  void loop(bool toLoop);
75 
81  bool seek(float seconds, bool relative);
82 
84  float getTotalAudioTime();
85 
87  int getTotalAudioSize();
88 
90  float getCurrentAudioTime();
91 
93  int getCurrentAudioPosition();
94 
95 
97  bool isValid() const;
98 
100  bool isPlaying() const;
101 
103  bool isPaused() const;
104 
106  bool isStopped() const;
107 
109  bool isLooping() const;
110 
113  void setPosition(float x, float y, float z);
114 
117  void setVelocity(float x, float y, float z);
118 
120 
122  void setDirection(float x, float y, float z);
123 
128  void setRolloffFactor(float rolloff);
129 
131 
134  void setStrength(float soundstrength);
135 
139  void setMinDistance(float minDistance);
140 
144  void setMaxDistance(float maxDistance);
145 
149  void setPitch(float pitch);
150 
154  void setVolume(float volume);
155 
159  void setMinVolume(float minVolume);
160 
164  void setMaxVolume(float maxVolume);
165 
170  void setInnerConeAngle(float innerAngle);
171 
176  void setOuterConeAngle(float outerAngle);
177 
181  void setOuterConeVolume(float outerVolume);
182 
186  void move(float x, float y, float z);
187 
189  void getPosition(float& x, float& y, float& z) const;
190 
192  void getVelocity(float& x, float& y, float& z) const;
193 
195  void getDirection(float& x, float& y, float& z) const;
196 
198  float getRolloffFactor() const;
199 
201  float getStrength() const;
202 
204  float getMinDistance() const;
205 
207  float getMaxDistance() const;
208 
210  float getPitch() const;
211 
213  float getVolume() const;
214 
216  float getMinVolume() const;
217 
219  float getMaxVolume() const;
220 
222  float getInnerConeAngle() const;
223 
225  float getOuterConeAngle() const;
226 
228  float getOuterConeVolume() const;
229  };
230 
235  class PE_CORE_DECL ParaAudio
236  {
237  public:
240  static bool IsAudioEngineEnabled();
241 
243  static void EnableAudioEngine(bool bEnable);
244 
245 
249  static void SetVolume(float fVolume);
250 
254  static float GetVolume();
255 
262  static ParaAudioSource Create(const char* sName, const char* sWavePath, bool bStream);
263 
265  static ParaAudioSource Get(const char* sName);
266 
273  static ParaAudioSource CreateGet(const char* sName, const char* sWavePath, bool bStream);
274 
290  static void SetDistanceModel(int eDistModel);
291 
293  //
294  // handy functions to play audio files.
295  //
297 
303  static bool PlayWaveFile(const char* szWavePath, int nLoop);
304  static bool PlayWaveFile1(const char* szWavePath);
308  static int PlayMidiMsg(DWORD dwMsg);
309 
317  static bool StopWaveFile(const char* szWavePath, bool bImmediateStop);
318  static bool StopWaveFile1(const char* szWavePath);
319 
324  static bool ReleaseWaveFile(const char* szWavePath);
325 
326 
328  //
329  // the audio listener
330  //
332 
334  //Note that you will still have to set velocity after this call for proper doppler effects.
335  //Use move() if you'd like to have cAudio automatically handle velocity for you.
336  //@param pos: New position for the listener. */
337  //static void setPosition(float x, float y, float z);
338 
340  //@param dir: New direction vector for the listener.
341  //*/
342  //static void setDirection(float x, float y, float z);
343 
345  //Default up vector is Y+, same as OpenGL.
346  //@param up: New up vector for the listener. */
347  //static void setUpVector(float x, float y, float z);
348 
350  //@param vel: New velocity for the listener. */
351  //static void setVelocity(float x, float y, float z);
352 
354  //Velocity will be set to new position - last position
355  //@param pos: New position to move the listener to. */
356  //static void move(const PARAVECTOR3& pos);
357 
359  //static void getPosition(float& x, float& y, float& z) const;
360 
362  //static void getDirection(float& x, float& y, float& z) const;
363 
365  //static void getUpVector(float& x, float& y, float& z) const;
366 
368  //static void getVelocity(float& x, float& y, float& z) const;
369  };
370 }
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: PEtypes.h:507
It represents a 2D or 3D audio source object.
Definition: ParaScriptingAudio.h:28
for luabind, The main drawback of this approach is that the compilation time will increase for the fi...
Definition: luaSQLite.cpp:1971