SoundEnvironment.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/SoundEnvironment.h $*
  25. * *
  26. * Author:: Ian Leslie *
  27. * *
  28. * $Modtime:: 4/20/01 7:01p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef SOUNDENVIRONMENT_H
  36. #define SOUNDENVIRONMENT_H
  37. // Includes.
  38. #include "refcount.h"
  39. // Class declarations.
  40. class CameraClass;
  41. class PhysicsSceneClass;
  42. // A simple class that, upon each update, will determine of there is an object vertically
  43. // above the camera (at any height). If so then an amplitude value is attenuated. If, the
  44. // camera is also in an environment zone, then the amplitude is attenuated further. Amplitude
  45. // values are in the range 0..1. This class also uses a small mixing buffer so that amplitude
  46. // changes occur smoothly over time.
  47. class SoundEnvironmentClass : public RefCountClass
  48. {
  49. public:
  50. SoundEnvironmentClass();
  51. ~SoundEnvironmentClass();
  52. void Reset();
  53. void Update (PhysicsSceneClass *scene, CameraClass *camera);
  54. float Get_Amplitude() {return (AmplitudeSum / AMPLITUDE_BUFFER_SIZE);}
  55. void Add_User() {UserCount++;} // Call to indicate that you want to start using this object.
  56. void Remove_User() {UserCount--;} // Call to indicate that you no longer need this object.
  57. protected:
  58. enum {
  59. AMPLITUDE_BUFFER_SIZE = 8
  60. };
  61. unsigned UserCount;
  62. unsigned AmplitudeIndex;
  63. float AmplitudeSum;
  64. float *AmplitudeBuffer;
  65. };
  66. #endif // SOUNDENVIRONMENT_H