-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSound.h
39 lines (29 loc) · 1.01 KB
/
Sound.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef _SOUND_H
#define _SOUND_H
#include <memory>
#include "Audio.h"
#include "Node.h"
class Sound : public Node
{
protected:
std::unique_ptr<Audio::Source> m_spSource;
std::unique_ptr<Audio::Buffer> m_spBuffer;
public:
Sound(Audio::Buffer* buf, unsigned int flags = 0) {
m_spBuffer.reset(buf);
m_spSource.reset(new Audio::Source(flags));
m_spSource->bind(m_spBuffer.get());
m_spSource->refresh();
m_spSource->play();
}
virtual ~Sound() {}
virtual void logicSelf(unsigned int advance) {
m_spSource->refresh();
}
virtual void renderSelf(IPartitioner* partitioner, unsigned int flags = 0) const {}
Audio::Source* source() { return m_spSource.get(); }
Audio::Buffer* buffer() { return m_spBuffer.get(); }
virtual std::string nodeTypeString() { return "sound"; }
virtual SCOPED_ENUM_TYPE(NodeType) nodeType() { return NodeType::SOUND; }
};
#endif