1 | /*! |
---|
2 | \file sound_engine.h |
---|
3 | \brief Definition of the SoundEngine singleton Class |
---|
4 | |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef _SOUND_ENGINE_H |
---|
8 | #define _SOUND_ENGINE_H |
---|
9 | |
---|
10 | #include "base_object.h" |
---|
11 | #include "alincl.h" |
---|
12 | |
---|
13 | // FORWARD DEFINITION |
---|
14 | class PNode; |
---|
15 | template<class T> class tList; |
---|
16 | |
---|
17 | |
---|
18 | //! A class that represents a datastructure to play Sounds. |
---|
19 | class SoundBuffer |
---|
20 | { |
---|
21 | public: |
---|
22 | SoundBuffer(const char* fileName); |
---|
23 | ~SoundBuffer(void); |
---|
24 | |
---|
25 | private: |
---|
26 | ALuint bufferID; //!< The address of the Buffer. |
---|
27 | |
---|
28 | ALsizei size; //!< The size of the Buffer. |
---|
29 | ALboolean loop; //!< loop information. |
---|
30 | }; |
---|
31 | |
---|
32 | //! A class that represents a SoundSource |
---|
33 | class SoundSource |
---|
34 | { |
---|
35 | public: |
---|
36 | SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL); |
---|
37 | ~SoundSource(void); |
---|
38 | |
---|
39 | /** \retruns The ID of the Source */ |
---|
40 | inline ALuint getID(void) { return this->sourceID; } |
---|
41 | /** \returns the SourceNode of this Source */ |
---|
42 | inline PNode* getNode(void) { return this->sourceNode;} |
---|
43 | |
---|
44 | private: |
---|
45 | ALuint sourceID; //!< The ID of the Source |
---|
46 | SoundBuffer* buffer; //!< The buffer to play in this source. |
---|
47 | PNode* sourceNode; //!< The SourceNode represente the position/velocity... of this source. |
---|
48 | }; |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | //! A class that handles audio via the openAudioLibrary |
---|
53 | class SoundEngine : public BaseObject { |
---|
54 | |
---|
55 | public: |
---|
56 | static SoundEngine* getInstance(void); |
---|
57 | virtual ~SoundEngine(void); |
---|
58 | |
---|
59 | void setListener(PNode* listener); |
---|
60 | |
---|
61 | void addBuffer(SoundBuffer* buffer); |
---|
62 | void removeBuffer(SoundBuffer* buffer); |
---|
63 | void addSource(SoundSource* source); |
---|
64 | void removeSource(SoundSource* source); |
---|
65 | |
---|
66 | |
---|
67 | void update(void); |
---|
68 | |
---|
69 | private: |
---|
70 | SoundEngine(void); |
---|
71 | static SoundEngine* singletonRef; |
---|
72 | |
---|
73 | bool initAudio(void); |
---|
74 | |
---|
75 | PNode* listener; //!< The listener of the Scene |
---|
76 | tList<SoundBuffer>* bufferList; //!< A list of buffers |
---|
77 | tList<SoundSource>* sourceList; //!< A list for all the sources in the scene. |
---|
78 | |
---|
79 | }; |
---|
80 | |
---|
81 | #endif /* _SOUND_ENGINE_H */ |
---|