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