[4838] | 1 | /*! |
---|
[5386] | 2 | * @file sound_source.h |
---|
| 3 | * @brief Definition of the SoundSource. |
---|
[3245] | 4 | */ |
---|
[1853] | 5 | |
---|
[5386] | 6 | #ifndef _SOUND_SOURCE_H |
---|
| 7 | #define _SOUND_SOURCE_H |
---|
[1853] | 8 | |
---|
[3543] | 9 | #include "base_object.h" |
---|
[5386] | 10 | #include "alincl.h" |
---|
[1853] | 11 | |
---|
[4838] | 12 | // FORWARD DECLARATION |
---|
[5386] | 13 | class SoundBuffer; |
---|
| 14 | class PNode; |
---|
[3543] | 15 | |
---|
[5386] | 16 | //! A class that represents a SoundSource |
---|
| 17 | class SoundSource : public BaseObject |
---|
| 18 | { |
---|
| 19 | public: |
---|
| 20 | SoundSource(const PNode* sourceNode = NULL, const SoundBuffer* buffer = NULL); |
---|
[7299] | 21 | SoundSource(const SoundSource& source); |
---|
| 22 | SoundSource& operator=(const SoundSource& source); |
---|
| 23 | bool operator==(const SoundSource& source); |
---|
| 24 | |
---|
[6981] | 25 | virtual ~SoundSource(); |
---|
[3543] | 26 | |
---|
[5386] | 27 | // user interaction |
---|
| 28 | void play(); |
---|
| 29 | void play(const SoundBuffer* buffer); |
---|
| 30 | void stop(); |
---|
| 31 | void pause(); |
---|
| 32 | void rewind(); |
---|
[2036] | 33 | |
---|
[5386] | 34 | // development functions |
---|
| 35 | /** @returns The ID of this Source */ |
---|
[7317] | 36 | inline ALuint getID() const { return this->sourceID; }; |
---|
[5930] | 37 | /** @returns true, if the Source is Playing */ |
---|
| 38 | inline bool isPlaying() const { return this->bPlay; }; |
---|
[7317] | 39 | void setSourceNode(const PNode* sourceNode); |
---|
[5386] | 40 | /** @returns the SoundBuffer of this Source */ |
---|
[7317] | 41 | inline const SoundBuffer* getBuffer() const { return this->buffer; }; |
---|
[5386] | 42 | /** @returns the SourceNode of this Source */ |
---|
[7317] | 43 | inline const PNode* getNode() const { return this->sourceNode; }; |
---|
| 44 | /** @param resident if the Source is Resident */ |
---|
| 45 | inline void setResident(bool resident) { this->resident = resident; }; |
---|
| 46 | /** @returns true if the alSource is Resident */ |
---|
| 47 | inline bool isResident() const { return this->resident; }; |
---|
[1853] | 48 | |
---|
[5386] | 49 | void setRolloffFactor(ALfloat rolloffFactor); |
---|
[1853] | 50 | |
---|
[7317] | 51 | static void resetSource(ALuint sourceID); |
---|
| 52 | |
---|
[5386] | 53 | private: |
---|
[7317] | 54 | bool retrieveSource(); |
---|
| 55 | |
---|
| 56 | private: |
---|
[5917] | 57 | bool bPlay; //!< If the Source is Playing. |
---|
[7317] | 58 | bool resident; //!< If the alSource should be resident (if true, the alSource will be returned on deletion). |
---|
[5386] | 59 | ALuint sourceID; //!< The ID of the Source |
---|
| 60 | const SoundBuffer* buffer; //!< The buffer to play in this source. |
---|
[6634] | 61 | const PNode* sourceNode; //!< The SourceNode representing the position/velocity... of this source. |
---|
[1853] | 62 | }; |
---|
[5386] | 63 | #endif /* _SOUND_SOURCE_H */ |
---|