sound_room_params.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*************************************************************************/
  2. /* sound_room_params.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef SOUND_ROOM_PARAMS_H
  30. #define SOUND_ROOM_PARAMS_H
  31. #include "scene/main/node.h"
  32. #include "servers/spatial_sound_server.h"
  33. #ifndef _3D_DISABLED
  34. #include "scene/3d/room_instance.h"
  35. class SoundRoomParams : public Node {
  36. OBJ_TYPE( SoundRoomParams, Node );
  37. public:
  38. enum Params {
  39. PARAM_SPEED_OF_SOUND_SCALE=SpatialSoundServer::ROOM_PARAM_SPEED_OF_SOUND_SCALE,
  40. PARAM_DOPPLER_FACTOR=SpatialSoundServer::ROOM_PARAM_DOPPLER_FACTOR,
  41. PARAM_PITCH_SCALE=SpatialSoundServer::ROOM_PARAM_PITCH_SCALE,
  42. PARAM_VOLUME_SCALE_DB=SpatialSoundServer::ROOM_PARAM_VOLUME_SCALE_DB,
  43. PARAM_REVERB_SEND=SpatialSoundServer::ROOM_PARAM_REVERB_SEND,
  44. PARAM_CHORUS_SEND=SpatialSoundServer::ROOM_PARAM_CHORUS_SEND,
  45. PARAM_ATTENUATION_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_SCALE,
  46. PARAM_ATTENUATION_HF_CUTOFF=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_CUTOFF,
  47. PARAM_ATTENUATION_HF_FLOOR_DB=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_FLOOR_DB,
  48. PARAM_ATTENUATION_HF_RATIO_EXP=SpatialSoundServer::ROOM_PARAM_ATTENUATION_HF_RATIO_EXP,
  49. PARAM_ATTENUATION_REVERB_SCALE=SpatialSoundServer::ROOM_PARAM_ATTENUATION_REVERB_SCALE,
  50. PARAM_MAX=SpatialSoundServer::ROOM_PARAM_MAX
  51. };
  52. enum Reverb {
  53. REVERB_SMALL,
  54. REVERB_MEDIUM,
  55. REVERB_LARGE,
  56. REVERB_HALL
  57. };
  58. private:
  59. RID room;
  60. float params[PARAM_MAX];
  61. Reverb reverb;
  62. bool force_params_for_all_sources;
  63. void _update_sound_room();
  64. protected:
  65. void _notification(int p_what);
  66. static void _bind_methods();
  67. public:
  68. void set_param(Params p_param, float p_value);
  69. float get_param(Params p_param) const;
  70. void set_reverb_mode(Reverb p_mode);
  71. Reverb get_reverb_mode() const;
  72. void set_force_params_to_all_sources(bool p_force);
  73. bool is_forcing_params_to_all_sources();
  74. SoundRoomParams();
  75. };
  76. VARIANT_ENUM_CAST(SoundRoomParams::Params);
  77. VARIANT_ENUM_CAST(SoundRoomParams::Reverb);
  78. #endif
  79. #endif // SOUND_ROOM_PARAMS_H