event_player.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*************************************************************************/
  2. /* event_player.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2014 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 EVENT_PLAYER_H
  30. #define EVENT_PLAYER_H
  31. #include "scene/main/node.h"
  32. #include "scene/resources/event_stream.h"
  33. class EventPlayer : public Node {
  34. OBJ_TYPE(EventPlayer,Node);
  35. enum {
  36. MAX_CHANNELS=256
  37. };
  38. Ref<EventStreamPlayback> playback;
  39. Ref<EventStream> stream;
  40. bool paused;
  41. bool autoplay;
  42. bool loops;
  43. float volume;
  44. float tempo_scale;
  45. float pitch_scale;
  46. float channel_volume[MAX_CHANNELS];
  47. bool _play;
  48. void _set_play(bool p_play);
  49. bool _get_play() const;
  50. protected:
  51. void _notification(int p_what);
  52. static void _bind_methods();
  53. public:
  54. void set_stream(const Ref<EventStream> &p_stream);
  55. Ref<EventStream> get_stream() const;
  56. void play();
  57. void stop();
  58. bool is_playing() const;
  59. void set_paused(bool p_paused);
  60. bool is_paused() const;
  61. void set_loop(bool p_enable);
  62. bool has_loop() const;
  63. void set_volume(float p_vol);
  64. float get_volume() const;
  65. void set_volume_db(float p_db);
  66. float get_volume_db() const;
  67. void set_pitch_scale(float p_scale);
  68. float get_pitch_scale() const;
  69. void set_tempo_scale(float p_scale);
  70. float get_tempo_scale() const;
  71. String get_stream_name() const;
  72. int get_loop_count() const;
  73. float get_pos() const;
  74. void seek_pos(float p_time);
  75. float get_length() const;
  76. void set_autoplay(bool p_vol);
  77. bool has_autoplay() const;
  78. void set_channel_volume(int p_channel,float p_volume);
  79. float get_channel_volume(int p_channel) const;
  80. float get_channel_last_note_time(int p_channel) const;
  81. EventPlayer();
  82. ~EventPlayer();
  83. };
  84. #endif // EVENT_PLAYER_H