sfxDSVoice.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 _SFXDSVOICE_H_
  23. #define _SFXDSVOICE_H_
  24. #ifndef _SFXVOICE_H_
  25. #include "sfx/sfxVoice.h"
  26. #endif
  27. #ifndef _SFXDSBUFFER_H_
  28. #include "sfx/dsound/sfxDSBuffer.h"
  29. #endif
  30. #include <dsound.h>
  31. class SFXDSDevice;
  32. class SFXDSVoice : public SFXVoice
  33. {
  34. typedef SFXVoice Parent;
  35. protected:
  36. SFXDSVoice( SFXDSDevice *device,
  37. SFXDSBuffer *buffer,
  38. IDirectSoundBuffer8 *dsBuffer,
  39. IDirectSound3DBuffer8 *dsBuffer3d );
  40. /// The device used to commit deferred settings.
  41. SFXDSDevice *mDevice;
  42. IDirectSoundBuffer8 *mDSBuffer;
  43. IDirectSound3DBuffer8 *mDSBuffer3D;
  44. bool mIsLooping;
  45. SFXDSBuffer* _getBuffer() const { return ( SFXDSBuffer* ) mBuffer.getPointer(); }
  46. /// Helper for converting floating point linear volume
  47. /// to a logrithmic integer volume for dsound.
  48. static LONG _linearToLogVolume( F32 linVolume );
  49. // SFXVoice
  50. virtual SFXStatus _status() const;
  51. virtual void _play();
  52. virtual void _pause();
  53. virtual void _stop();
  54. virtual void _seek( U32 sample );
  55. virtual U32 _tell() const;
  56. public:
  57. ///
  58. static SFXDSVoice* create( SFXDSDevice *device,
  59. SFXDSBuffer *buffer );
  60. ///
  61. virtual ~SFXDSVoice();
  62. // SFXVoice
  63. void setMinMaxDistance( F32 min, F32 max );
  64. void play( bool looping );
  65. void setVelocity( const VectorF& velocity );
  66. void setTransform( const MatrixF& transform );
  67. void setVolume( F32 volume );
  68. void setPitch( F32 pitch );
  69. void setCone( F32 innerAngle, F32 outerAngle, F32 outerVolume );
  70. };
  71. #endif // _SFXDSBUFFER_H_