event_stream.h
1 /*************************************************************************/
2 /* event_stream.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_STREAM_H
30 #define EVENT_STREAM_H
31 
32 #include "resource.h"
33 #include "servers/audio_server.h"
34 
36 
38 
39  class InternalEventStream : public AudioServer::EventStream {
40  public:
41  AudioMixer *_get_mixer(){ return get_mixer(); }
42  EventStreamPlayback *playback;
43  virtual void update(uint64_t p_usec) {
44 
45  playback->_update(get_mixer(),p_usec);
46  }
47 
48 
49  virtual ~InternalEventStream() {}
50  };
51 
52 
53  InternalEventStream estream;
54 
55  RID stream;
56  bool playing;
57 
58 
59 protected:
60 
61  virtual AudioMixer* _get_mixer() { return estream._get_mixer(); }
62  virtual Error _play()=0;
63  virtual bool _update(AudioMixer* p_mixer, uint64_t p_usec)=0;
64  virtual void _stop()=0;
65 public:
66 
67  virtual Error play();
68  virtual void stop();
69  virtual bool is_playing() const;
70 
71  virtual void set_paused(bool p_paused)=0;
72  virtual bool is_paused() const=0;
73 
74  virtual void set_loop(bool p_loop)=0;
75  virtual bool is_loop_enabled() const=0;
76 
77  virtual int get_loop_count() const=0;
78 
79  virtual float get_pos() const=0;
80  virtual void seek_pos(float p_time)=0;
81 
82  virtual void set_volume(float p_vol)=0;
83  virtual float get_volume() const=0;
84 
85  virtual void set_pitch_scale(float p_pitch_scale)=0;
86  virtual float get_pitch_scale() const=0;
87 
88  virtual void set_tempo_scale(float p_tempo_scale)=0;
89  virtual float get_tempo_scale() const=0;
90 
91  virtual void set_channel_volume(int p_channel,float p_volume)=0;
92  virtual float get_channel_volume(int p_channel) const=0;
93 
94  virtual float get_last_note_time(int p_channel) const=0;
97 
98 };
99 
100 class EventStream : public Resource {
101 
102  OBJ_TYPE(EventStream,Resource);
103  OBJ_SAVE_TYPE( EventStream ); //children are all saved as EventStream, so they can be exchanged
104 
105 public:
106 
107  virtual Ref<EventStreamPlayback> instance_playback()=0;
108 
109  virtual String get_stream_name() const=0;
110  virtual float get_length() const=0;
111  virtual int get_channel_count() const=0;
112 
113 
114 
115  EventStream();
116 };
117 
118 #endif // EVENT_STREAM_H
Definition: reference.h:40
Definition: event_stream.h:100
Definition: resource.h:89
Definition: rid.h:47
Definition: event_stream.h:35
Definition: ustring.h:64