sfxFMODVoice.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SFXFMODVOICE_H_
  23. #define _SFXFMODVOICE_H_
  24. #ifndef _SFXDEVICE_H_
  25. #include "sfx/sfxDevice.h"
  26. #endif
  27. #ifndef _SFXVOICE_H_
  28. #include "sfx/sfxVoice.h"
  29. #endif
  30. #ifndef _BITSET_H_
  31. #include "core/bitSet.h"
  32. #endif
  33. #include "fmod.h"
  34. class SFXSource;
  35. class SFXFMODBuffer;
  36. class SFXFMODDevice;
  37. class SFXFMODVoice : public SFXVoice
  38. {
  39. typedef SFXVoice Parent;
  40. friend class SFXFMODBuffer;
  41. protected:
  42. SFXFMODDevice *mDevice;
  43. mutable FMOD_CHANNEL *mChannel;
  44. enum ESettings
  45. {
  46. SET_MinMaxDistance = BIT( 0 ),
  47. SET_Velocity = BIT( 1 ),
  48. SET_Transform = BIT( 2 ),
  49. SET_Volume = BIT( 3 ),
  50. SET_Pitch = BIT( 4 ),
  51. SET_Cone = BIT( 5 ),
  52. SET_Priority = BIT( 6 ),
  53. SET_Reverb = BIT( 7 ),
  54. };
  55. BitSet32 mSetFlags;
  56. FMOD_MODE mMode;
  57. F32 mMinDistance;
  58. F32 mMaxDistance;
  59. F32 mVolume;
  60. F32 mPriority;
  61. F32 mFrequency;
  62. F32 mConeInnerAngle;
  63. F32 mConeOuterAngle;
  64. F32 mConeOuterVolume;
  65. FMOD_VECTOR mVelocity;
  66. FMOD_VECTOR mPosition;
  67. FMOD_VECTOR mDirection;
  68. FMOD_REVERB_CHANNELPROPERTIES mReverb;
  69. ///
  70. SFXFMODVoice( SFXFMODDevice *device,
  71. SFXFMODBuffer *buffer );
  72. // prep for playback
  73. bool _assignChannel();
  74. SFXFMODBuffer* _getBuffer() const { return ( SFXFMODBuffer* ) mBuffer.getPointer(); }
  75. // SFXVoice.
  76. virtual SFXStatus _status() const;
  77. virtual void _play();
  78. virtual void _pause();
  79. virtual void _stop();
  80. virtual void _seek( U32 sample );
  81. virtual U32 _tell() const;
  82. public:
  83. ///
  84. static SFXFMODVoice* create( SFXFMODDevice *device,
  85. SFXFMODBuffer *buffer );
  86. ///
  87. virtual ~SFXFMODVoice();
  88. /// SFXVoice
  89. void setMinMaxDistance( F32 min, F32 max );
  90. void play( bool looping );
  91. void setVelocity( const VectorF& velocity );
  92. void setTransform( const MatrixF& transform );
  93. void setVolume( F32 volume );
  94. void setPriority( F32 priority );
  95. void setPitch( F32 pitch );
  96. void setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume );
  97. void setReverb( const SFXSoundReverbProperties& reverb );
  98. bool isVirtual() const;
  99. };
  100. #endif // _SFXFMODBUFFER_H_