TDME2  1.9.200
AudioEntity.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
6 #include <tdme/audio/fwd-tdme.h>
7 #include <tdme/math/fwd-tdme.h>
8 #include <tdme/math/Vector3.h>
9 
10 using std::string;
11 
13 
14 /**
15  * Audio entity base class
16  * @author Andreas Drewke
17  */
19 {
20  friend class Audio;
21 
22 protected:
23  string id;
24  bool looping { false };
25  bool fixed { false };
26  float pitch { 1.0f };
27  float gain { 1.0f };
31 
32 protected:
33  // forbid class copy
35 
36  /**
37  * Constructor
38  */
39  inline AudioEntity(const string& id): id(id) {}
40 
41  /**
42  * Constructor
43  */
44  inline virtual ~AudioEntity() {}
45 
46  /**
47  * Initiates this OpenAL entity to OpenAl
48  */
49  virtual bool initialize() = 0;
50 
51  /**
52  * Commits properties to OpenAl
53  */
54  virtual void update() = 0;
55 
56  /**
57  * Dispose this entity from OpenAL
58  */
59  virtual void dispose() = 0;
60 
61 public:
62 
63  /**
64  * @return id
65  */
66  inline virtual const string& getId() const {
67  return id;
68  }
69 
70  /**
71  * @return if sound will be looped
72  */
73  inline virtual const bool isLooping() const {
74  return looping;
75  }
76 
77  /**
78  * Set looping
79  * @param looping if sound will be looped
80  */
81  inline virtual void setLooping(bool looping) {
82  this->looping = looping;
83  }
84 
85  /**
86  * @return fixed, means the sound will always played no matter where the position and listener is located
87  */
88  inline virtual const bool isFixed() const {
89  return fixed;
90  }
91 
92  /**
93  * Set this entity fixed, means the sound will always played no matter where the position and listener is located
94  * @param fixed fixed
95  */
96  inline virtual void setFixed(bool fixed) {
97  this->fixed = fixed;
98  }
99 
100  /**
101  * @return pitch
102  */
103  inline virtual const float getPitch() const {
104  return pitch;
105  }
106 
107  /**
108  * Set up pitch
109  * @param pitch pitch
110  */
111  inline virtual void setPitch(float pitch) {
112  this->pitch = pitch;
113  }
114 
115  /**
116  * @return gain
117  */
118  inline virtual const float getGain() const {
119  return gain;
120  }
121 
122  /**
123  * Set up gain
124  * @param gain gain
125  */
126  inline virtual void setGain(float gain) {
127  this->gain = gain;
128  }
129 
130  /**
131  * @return source position
132  */
133  inline virtual const Vector3& getSourcePosition() const {
134  return sourcePosition;
135  }
136 
137  /**
138  * Set source position
139  * @return source position
140  */
141  inline virtual void setSourcePosition(const Vector3& sourcePosition) {
142  this->sourcePosition = sourcePosition;
143  }
144 
145  /**
146  * @return source direction
147  */
148  inline virtual const Vector3& getSourceDirection() const {
149  return sourceDirection;
150  }
151 
152  /**
153  * Set source direction
154  * @param sourceDirection source direction
155  */
156  inline virtual void setSourceDirection(const Vector3& sourceDirection) {
157  this->sourceDirection = sourceDirection;
158  }
159 
160  /**
161  * @return source velocity
162  */
163  inline virtual const Vector3& getSourceVelocity() const {
164  return sourceVelocity;
165  }
166 
167  /**
168  * Set source velocity
169  * @param sourceVelocity source velocity
170  */
171  inline virtual void getSourceVelocity(const Vector3& sourceVelocity) {
172  this->sourceVelocity = sourceVelocity;
173  }
174 
175  /**
176  * @return if stream is playing
177  */
178  virtual bool isPlaying() = 0;
179 
180  /**
181  * Rewinds this audio entity
182  */
183  virtual void rewind() = 0;
184 
185  /**
186  * Plays this audio entity
187  */
188  virtual void play() = 0;
189 
190  /**
191  * Pauses this audio entity
192  */
193  virtual void pause() = 0;
194 
195  /**
196  * Stops this audio entity
197  */
198  virtual void stop() = 0;
199 
200 };
Audio entity base class.
Definition: AudioEntity.h:19
virtual const bool isLooping() const
Definition: AudioEntity.h:73
virtual void stop()=0
Stops this audio entity.
virtual void pause()=0
Pauses this audio entity.
virtual const Vector3 & getSourceDirection() const
Definition: AudioEntity.h:148
virtual void play()=0
Plays this audio entity.
virtual const bool isFixed() const
Definition: AudioEntity.h:88
virtual bool initialize()=0
Initiates this OpenAL entity to OpenAl.
virtual ~AudioEntity()
Constructor.
Definition: AudioEntity.h:44
virtual void setLooping(bool looping)
Set looping.
Definition: AudioEntity.h:81
virtual const Vector3 & getSourceVelocity() const
Definition: AudioEntity.h:163
virtual void setGain(float gain)
Set up gain.
Definition: AudioEntity.h:126
virtual void getSourceVelocity(const Vector3 &sourceVelocity)
Set source velocity.
Definition: AudioEntity.h:171
virtual void setPitch(float pitch)
Set up pitch.
Definition: AudioEntity.h:111
virtual const Vector3 & getSourcePosition() const
Definition: AudioEntity.h:133
virtual void update()=0
Commits properties to OpenAl.
virtual void setSourceDirection(const Vector3 &sourceDirection)
Set source direction.
Definition: AudioEntity.h:156
virtual const float getGain() const
Definition: AudioEntity.h:118
virtual const float getPitch() const
Definition: AudioEntity.h:103
virtual void rewind()=0
Rewinds this audio entity.
virtual void dispose()=0
Dispose this entity from OpenAL.
virtual bool isPlaying()=0
virtual void setSourcePosition(const Vector3 &sourcePosition)
Set source position.
Definition: AudioEntity.h:141
virtual void setFixed(bool fixed)
Set this entity fixed, means the sound will always played no matter where the position and listener i...
Definition: AudioEntity.h:96
virtual const string & getId() const
Definition: AudioEntity.h:66
Interface to audio module.
Definition: Audio.h:29
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6