3#include "sound_bakery/core/core_include.h"
5#include "sound_bakery/node/container/sequence_container.h"
7#include <boost/msm/back/state_machine.hpp>
8#include <boost/msm/front/state_machine_def.hpp>
9#include <boost/msm/front/functor_row.hpp>
10#include <boost/msm/front/euml/common.hpp>
11#include <boost/msm/front/euml/operator.hpp>
12#include <boost/msm/front/euml/state_grammar.hpp>
25 sc_dsp* highpass =
nullptr;
26 std::unique_ptr<sc_node_group, SC_NODE_GROUP_DELETER> nodeGroup;
29 enum class node_instance_type
39 node_instance_type type = node_instance_type::main;
51 float stopTime = 0.0f;
61 float deltaTime = 0.0f;
67 struct SB_CLASS
node_instance_fsm :
public boost::msm::front::state_machine_def<node_instance_fsm>
75 typedef boost::mpl::vector1<flag_playing> flag_list;
79 typedef boost::mpl::vector1<flag_playing> flag_list;
83 typedef boost::mpl::vector1<flag_stopped> flag_list;
86 auto action_init(
const event_init& init) -> void;
87 auto action_play(
const event_play& play) -> void;
88 auto action_pause(
const event_pause& pause) -> void;
89 auto action_stop(
const event_stop& stop) -> void;
94 template <
class event_
class,
class state_machine_
class,
class source_state_
class,
class target_state_
class>
95 void operator()(event_class
const& update, state_machine_class& stateMachine, source_state_class&, target_state_class&)
97 if (stateMachine.m_soundInstance)
99 if (ma_sound_at_end(&stateMachine.m_soundInstance->sound) == MA_TRUE)
104 else if (!stateMachine.m_children.empty())
106 unsigned int stoppedChildren = 0;
108 for (
const auto& child : stateMachine.m_children)
112 if (!child->is_playing())
118 const bool allChildrenHaveStopped = stoppedChildren == stateMachine.m_children.size();
120 if (allChildrenHaveStopped)
123 if (stateMachine.m_referencingNode->get_object_type() == rttr::type::get<sbk::engine::sequence_container>())
125 stateMachine.m_children.clear();
126 ++stateMachine.m_numTimesPlayed;
127 stateMachine.init_child();
140 auto guard_init(
const event_init& init) -> bool;
147 row<state_uninit, event_init, state_init, &node_instance_fsm::action_init, &node_instance_fsm::guard_init>,
148 a_row<state_init, event_play, state_playing, &node_instance_fsm::action_play>,
149 a_row<state_playing, event_stop, state_stopped, &node_instance_fsm::action_stop>,
150 a_row<state_playing, event_virtualise, state_virtual, &node_instance_fsm::action_virtualise>,
151 a_row<state_virtual, event_devirtualise, state_playing, &node_instance_fsm::action_devirtualise>,
152 boost::msm::front::Row<state_playing, event_update, boost::msm::front::none, action_update, boost::msm::front::none>
158 auto init_node_group(
const event_init& init) -> sb_result;
159 void init_callbacks();
163 auto set_volume(
float oldVolume,
float newVolume) -> void;
164 auto set_pitch(
float oldPitch,
float newPitch) -> void;
165 auto set_lowpass(
float oldLowpass,
float newLowpass) -> void;
166 auto set_highpass(
float oldHighpass,
float newHighpass) -> void;
168 std::shared_ptr<node> m_referencingNode;
172 std::shared_ptr<node_instance> m_parent;
173 std::vector<std::shared_ptr<node_instance>> m_children;
174 std::unique_ptr<sc_sound_instance, SC_SOUND_INSTANCE_DELETER> m_soundInstance;
175 unsigned int m_numTimesPlayed = 0;
187 auto init(
const event_init& init) -> sb_result;
188 auto play() -> sb_result;
189 auto stop(
float fadeTime = 0.0f) -> sb_result;
190 auto update() -> sb_result;
192 auto is_playing()
const -> bool;
193 auto is_stopped()
const -> bool;
195 auto get_referencing_node()
const noexcept -> std::shared_ptr<node>;
200 boost::msm::back::state_machine<node_instance_fsm> m_stateMachine;
Definition database_ptr.h:23
Base object that all sound Bakery objects should inherit from.
Definition object.h:23
Definition gameobject.h:14
NodeInstances represent runtime versions of Nodes, either containers or busses.
Definition node_instance.h:183
Definition node_instance.h:57
Definition node_instance.h:37
Definition node_instance.h:47
Definition node_instance.h:44
Definition node_instance.h:50
Definition node_instance.h:60
Definition node_instance.h:54
Definition node_instance.h:64
Definition node_instance.h:65
Owns a node group and applies DSP effects to it.
Definition node_instance.h:23
Definition node_instance.h:93
Definition node_instance.h:72
Definition node_instance.h:74
Definition node_instance.h:82
Definition node_instance.h:71
Definition node_instance.h:78
Definition node_instance.h:154
Definition node_instance.h:68
Definition sound_chef_common.h:168
ma_node with an additional enum descriptor.
Definition sound_chef_common.h:181
Groups nodes/DSPs together into one.
Definition sound_chef_common.h:208