SoundEvent.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <string>
  10. #include "Math.h"
  11. class SoundEvent
  12. {
  13. public:
  14. SoundEvent();
  15. // Returns true if associated FMOD event still exists
  16. bool IsValid();
  17. // Restart event from beginning
  18. void Restart();
  19. // Stop this event
  20. void Stop(bool allowFadeOut = true);
  21. // Setters
  22. void SetPaused(bool pause);
  23. void SetVolume(float value);
  24. void SetPitch(float value);
  25. void SetParameter(const std::string& name, float value);
  26. // Getters
  27. bool GetPaused() const;
  28. float GetVolume() const;
  29. float GetPitch() const;
  30. float GetParameter(const std::string& name);
  31. // Positional
  32. bool Is3D() const;
  33. void Set3DAttributes(const Matrix4& worldTrans);
  34. protected:
  35. // Make this constructor protected and AudioSystem a friend
  36. // so that only AudioSystem can access this constructor.
  37. friend class AudioSystem;
  38. SoundEvent(class AudioSystem* system, unsigned int id);
  39. private:
  40. class AudioSystem* mSystem;
  41. unsigned int mID;
  42. };