Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
node.h
1#pragma once
2
3#include "sound_bakery/core/core_include.h"
4#include "sound_bakery/effect/effect.h"
5#include "sound_bakery/parameter/parameter.h"
6
7namespace SB::Engine
8{
9 enum SB_NODE_STATUS
10 {
11 // Has no parent and no bus
12 SB_NODE_NULL,
13 // Has a parent node
14 SB_NODE_MIDDLE,
15 // Has no parent but outputs to a bus
16 SB_NODE_TOP
17 };
18
19 class SB_CLASS NodeBase : public SB::Core::DatabaseObject
20 {
21 public:
22 ~NodeBase();
23
24 public:
25 virtual void setParentNode(const SB::Core::DatabasePtr<NodeBase>& parent);
26 virtual void setOutputBus(const SB::Core::DatabasePtr<NodeBase>& bus);
27
28 SB_NODE_STATUS getNodeStatus() const noexcept;
29
30 NodeBase* parent() const;
31 NodeBase* outputBus() const;
32
33 virtual bool canAddChild(const SB::Core::DatabasePtr<NodeBase>& child) const;
34
35 void addChild(const SB::Core::DatabasePtr<NodeBase>& child);
36 void removeChild(const SB::Core::DatabasePtr<NodeBase>& child);
37
38 std::vector<NodeBase*> getChildren() const;
39 std::size_t getChildCount() const;
40 bool hasChild(const SB::Core::DatabasePtr<NodeBase>& test) const;
41
42 void gatherAllDescendants(std::vector<NodeBase*>& descendants) const;
43 void gatherAllParents(std::vector<NodeBase*>& parents) const;
44
45 protected:
48 std::unordered_set<SB::Core::DatabasePtr<NodeBase>> m_childNodes;
49
50 REGISTER_REFLECTION(NodeBase, SB::Core::DatabaseObject)
51 };
52
56 class SB_CLASS Node : public NodeBase
57 {
58 public:
59 SB::Core::FloatProperty m_volume = SB::Core::FloatProperty(1.0f, 0.0f, 1.0f);
60 SB::Core::FloatProperty m_pitch = SB::Core::FloatProperty(1.0f, 0.0f, 1.0f);
61 SB::Core::FloatProperty m_lowpass = SB::Core::FloatProperty(1.0f, 0.0f, 100.0f);
62 SB::Core::FloatProperty m_highpass = SB::Core::FloatProperty(1.0f, 0.0f, 100.0f);
63
64 std::vector<SB::Core::DatabasePtr<EffectDescription>> m_effectDescriptions;
65
69 virtual void gatherParameters(GlobalParameterList& parameters);
70
71 void addEffect(sc_dsp_type type);
72
73 protected:
80 virtual void gatherParametersFromThis(GlobalParameterList& parameters) { (void)parameters; }
81
82 REGISTER_REFLECTION(Node, NodeBase)
83 };
84} // namespace SB::Engine
Base object type for any object that can exist in the editor/database. Holds an ID and name.
Definition database_object.h:22
Definition database_ptr.h:23
Definition node.h:20
Root node that builds the core graph of sounds and busses.
Definition node.h:57
virtual void gatherParametersFromThis(GlobalParameterList &parameters)
Appends parameters from this node that are relevant to the runtime output.
Definition node.h:80
Holds a list of parameters.
Definition parameter.h:224