Audio.pkg 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. $#include "Audio.h"
  2. /// %Audio subsystem.
  3. class Audio : public Object
  4. {
  5. public:
  6. /// Initialize sound output with specified buffer length and output mode.
  7. bool SetMode(int bufferLengthMSec, int mixRate, bool stereo, bool interpolation = true);
  8. /// Run update on sound sources. Not required for continued playback, but frees unused sound sources & sounds and updates 3D positions.
  9. void Update(float timeStep);
  10. /// Restart sound output.
  11. bool Play();
  12. /// Suspend sound output.
  13. void Stop();
  14. /// Set master gain on a specific sound type such as sound effects, music or voice.
  15. void SetMasterGain(SoundType type, float gain);
  16. /// Set active sound listener for 3D sounds.
  17. void SetListener(SoundListener* listener);
  18. /// Stop any sound source playing a certain sound clip.
  19. void StopSound(Sound* sound);
  20. /// Return byte size of one sample.
  21. unsigned GetSampleSize() const { return sampleSize_; }
  22. /// Return mixing rate.
  23. int GetMixRate() const { return mixRate_; }
  24. /// Return whether output is interpolated.
  25. bool GetInterpolation() const { return interpolation_; }
  26. /// Return whether output is stereo.
  27. bool IsStereo() const { return stereo_; }
  28. /// Return whether audio is being output.
  29. bool IsPlaying() const { return playing_; }
  30. /// Return whether an audio stream has been reserved.
  31. bool IsInitialized() const { return deviceID_ != 0; }
  32. /// Return master gain for a specific sound source type.
  33. float GetMasterGain(SoundType type) const;
  34. /// Return active sound listener.
  35. SoundListener* GetListener() const;
  36. /// Add a sound source to keep track of. Called by SoundSource.
  37. void AddSoundSource(SoundSource* soundSource);
  38. /// Remove a sound source. Called by SoundSource.
  39. void RemoveSoundSource(SoundSource* soundSource);
  40. /// Return sound type specific gain multiplied by master gain.
  41. float GetSoundSourceMasterGain(SoundType type) const { return masterGain_[SOUND_MASTER] * masterGain_[type]; }
  42. };