SoundSource.pkg 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. $#include "SoundSource.h"
  2. /// %Sound source component with stereo position.
  3. class SoundSource : public Component
  4. {
  5. public:
  6. /// Play a sound.
  7. void Play(Sound* sound);
  8. /// Play a sound with specified frequency.
  9. void Play(Sound* sound, float frequency);
  10. /// Play a sound with specified frequency and gain.
  11. void Play(Sound* sound, float frequency, float gain);
  12. /// Play a sound with specified frequency, gain and panning.
  13. void Play(Sound* sound, float frequency, float gain, float panning);
  14. /// Stop playback.
  15. void Stop();
  16. /// Set sound type, determines the master gain group.
  17. void SetSoundType(SoundType type);
  18. /// Set frequency.
  19. void SetFrequency(float frequency);
  20. /// Set gain. 0.0 is silence, 1.0 is full volume.
  21. void SetGain(float gain);
  22. /// Set attenuation. 1.0 is unaltered. Used for distance attenuated playback.
  23. void SetAttenuation(float attenuation);
  24. /// Set stereo panning. -1.0 is full left and 1.0 is full right.
  25. void SetPanning(float panning);
  26. /// Set whether sound source will be automatically removed from the scene node when playback stops.
  27. void SetAutoRemove(bool enable);
  28. /// Set new playback position.
  29. void SetPlayPosition(signed char* pos);
  30. /// Return sound.
  31. Sound* GetSound() const { return sound_; }
  32. /// Return playback position.
  33. volatile signed char* GetPlayPosition() const { return position_; }
  34. /// Return sound type, determines the master gain group.
  35. SoundType GetSoundType() const { return soundType_; }
  36. /// Return playback time position.
  37. float GetTimePosition() const { return timePosition_; }
  38. /// Return frequency.
  39. float GetFrequency() const { return frequency_; }
  40. /// Return gain.
  41. float GetGain() const { return gain_; }
  42. /// Return attenuation.
  43. float GetAttenuation() const { return attenuation_; }
  44. /// Return stereo panning.
  45. float GetPanning() const { return panning_; }
  46. /// Return autoremove mode.
  47. bool GetAutoRemove() const { return autoRemove_; }
  48. /// Return whether is playing.
  49. bool IsPlaying() const;
  50. /// Play a sound without locking the audio mutex. Called internally.
  51. void PlayLockless(Sound* sound);
  52. /// Stop sound without locking the audio mutex. Called internally.
  53. void StopLockless();
  54. };