event_player.h
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-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 EVENT_PLAYER_H
30 #define EVENT_PLAYER_H
31 
32 
33 #include "scene/main/node.h"
34 #include "scene/resources/event_stream.h"
35 class EventPlayer : public Node {
36 
37  OBJ_TYPE(EventPlayer,Node);
38 
39 
40  enum {
41  MAX_CHANNELS=256
42  };
43 
44  Ref<EventStreamPlayback> playback;
45  Ref<EventStream> stream;
46  bool paused;
47  bool autoplay;
48  bool loops;
49  float volume;
50 
51  float tempo_scale;
52  float pitch_scale;
53 
54  float channel_volume[MAX_CHANNELS];
55  bool _play;
56  void _set_play(bool p_play);
57  bool _get_play() const;
58 protected:
59  void _notification(int p_what);
60 
61  static void _bind_methods();
62 
63 public:
64 
65  void set_stream(const Ref<EventStream> &p_stream);
66  Ref<EventStream> get_stream() const;
67 
68  void play();
69  void stop();
70  bool is_playing() const;
71 
72  void set_paused(bool p_paused);
73  bool is_paused() const;
74 
75  void set_loop(bool p_enable);
76  bool has_loop() const;
77 
78  void set_volume(float p_vol);
79  float get_volume() const;
80 
81  void set_volume_db(float p_db);
82  float get_volume_db() const;
83 
84  void set_pitch_scale(float p_scale);
85  float get_pitch_scale() const;
86 
87  void set_tempo_scale(float p_scale);
88  float get_tempo_scale() const;
89 
90  String get_stream_name() const;
91 
92  int get_loop_count() const;
93 
94  float get_pos() const;
95  void seek_pos(float p_time);
96  float get_length() const;
97  void set_autoplay(bool p_vol);
98  bool has_autoplay() const;
99 
100  void set_channel_volume(int p_channel,float p_volume);
101  float get_channel_volume(int p_channel) const;
102 
103  float get_channel_last_note_time(int p_channel) const;
104 
105  EventPlayer();
106  ~EventPlayer();
107 };
108 
109 #endif // EVENT_PLAYER_H
Definition: event_player.h:35
Definition: node.h:42
Definition: ustring.h:64