TDME2  1.9.200
Sound.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>
8 
9 using std::string;
10 
12 
13 /**
14  * Sound audio entity implementation
15  * @author Andreas Drewke
16  */
17 class tdme::audio::Sound final
18  : public AudioEntity
19 {
20  friend class Audio;
21 
22 private:
23  bool initiated { false };
24  string pathName;
25  string fileName;
26  string bufferId;
27  uint32_t alBufferId { 0 };
28  uint32_t alSourceId { 0 };
29 
30 public:
31  // forbid class copy
33 
34  /**
35  * Protected constructor
36  * @param id id
37  * @param pathName path name
38  * @param fileName file name
39  */
40  inline Sound(const string& id, const string& pathName, const string& fileName) : AudioEntity(id) {
41  this->bufferId = pathName + "/" + fileName;
42  this->pathName = pathName;
43  this->fileName = fileName;
44  }
45 
46  /**
47  * Destructor
48  */
49  inline ~Sound() {
50  }
51 
52  // overridden methods
53  bool isPlaying() override;
54  void rewind() override;
55  void play() override;
56  void pause() override;
57  void stop() override;
58 
59 protected:
60  // overridden methods
61  bool initialize() override;
62  void update() override;
63  void dispose() override;
64 };
Audio entity base class.
Definition: AudioEntity.h:19
Interface to audio module.
Definition: Audio.h:29
Sound audio entity implementation.
Definition: Sound.h:19
void play() override
Plays this audio entity.
Definition: Sound.cpp:59
void rewind() override
Rewinds this audio entity.
Definition: Sound.cpp:48
void dispose() override
Dispose this entity from OpenAL.
Definition: Sound.cpp:215
uint32_t alSourceId
Definition: Sound.h:28
void update() override
Commits properties to OpenAl.
Definition: Sound.cpp:197
bool initiated
Definition: Sound.h:23
bool initialize() override
Initiates this OpenAL entity to OpenAl.
Definition: Sound.cpp:94
string fileName
Definition: Sound.h:25
string pathName
Definition: Sound.h:24
bool isPlaying() override
Definition: Sound.cpp:41
uint32_t alBufferId
Definition: Sound.h:27
void stop() override
Stops this audio entity.
Definition: Sound.cpp:83
~Sound()
Destructor.
Definition: Sound.h:49
string bufferId
Definition: Sound.h:26
void pause() override
Pauses this audio entity.
Definition: Sound.cpp:72
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6