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 sbk::engine
8{
9 enum SB_NODE_STATUS
10 {
11 // Has no get_parent and no bus
12 SB_NODE_NULL,
13 // Has a get_parent node
14 SB_NODE_MIDDLE,
15 // Has no get_parent but outputs to a bus
16 SB_NODE_TOP
17 };
18
22 class SB_CLASS node_base : public sbk::core::database_object
23 {
24 public:
25 ~node_base();
26
27 virtual void set_parent_node(const sbk::core::database_ptr<node_base>& parent);
28 virtual void set_output_bus(const sbk::core::database_ptr<node_base>& bus);
29
30 node_base* get_parent() const;
31 node_base* get_output_bus() const;
32
33 SB_NODE_STATUS getNodeStatus() const noexcept;
34
35 virtual bool can_add_children() const; //< Can any children be added to this node?
36 virtual bool can_add_child_type(const rttr::type& childType) const; //< Can this type be added to the child?
37 bool can_add_child(const sbk::core::database_ptr<node_base>& child) const; //< Can this runtime child be added?
38
39 virtual bool can_add_parent() const; //< Can any parents be added to this node?
40 virtual bool can_add_parent_type(const rttr::type& parentType) const; //< Can this type be added as a get_parent?
41
42 void addChild(const sbk::core::database_ptr<node_base>& child);
43 void removeChild(const sbk::core::database_ptr<node_base>& child);
44
45 std::vector<node_base*> getChildren() const;
46 std::size_t getChildCount() const;
47 bool hasChild(const sbk::core::database_ptr<node_base>& test) const;
48
49 void gatherAllDescendants(std::vector<node_base*>& descendants) const;
50 void gatherAllParents(std::vector<node_base*>& parents) const;
51
52 protected:
55 std::unordered_set<sbk::core::database_ptr<node_base>> m_childNodes;
56
57 REGISTER_REFLECTION(node_base, sbk::core::database_object)
58 };
59
63 class SB_CLASS node : public node_base
64 {
65 public:
66 sbk::core::float_property m_volume = sbk::core::float_property(1.0f, 0.0f, 1.0f);
67 sbk::core::float_property m_pitch = sbk::core::float_property(1.0f, 0.0f, 1.0f);
68 sbk::core::float_property m_lowpass = sbk::core::float_property(1.0f, 0.0f, 100.0f);
69 sbk::core::float_property m_highpass = sbk::core::float_property(1.0f, 0.0f, 100.0f);
70
71 std::vector<sbk::core::database_ptr<effect_description>> m_effectDescriptions;
72
76 virtual void gatherParameters(global_parameter_list& parameters);
77
78 void addEffect(sc_dsp_type type);
79
80 protected:
87 virtual void gatherParametersFromThis(global_parameter_list& parameters) { (void)parameters; }
88
89 REGISTER_REFLECTION(node, node_base)
90 };
91} // namespace sbk::engine
Base object type for any object that can exist in the editor/database. Holds an ID and name.
Definition database_object.h:12
Definition database_ptr.h:23
Definition bus.h:10
Generic node that can have a get_parent and own children.
Definition node.h:23
Root node that builds the core graph of sounds and busses.
Definition node.h:64
virtual void gatherParametersFromThis(global_parameter_list &parameters)
Appends parameters from this node that are relevant to the runtime output.
Definition node.h:87
Holds a list of parameters.
Definition parameter.h:227