MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ Trigger()

MAYAFLUX_API Vruta::SoundRoutine MayaFlux::Kriya::Trigger ( bool  target_state,
std::function< void()>  callback,
std::shared_ptr< Nodes::Generator::Logic >  logic_node 
)

Coroutine that executes callback when logic node changes to specific state.

Parameters
logic_nodeLogic node to monitor (creates default threshold node if null)
target_stateState to trigger on (true/false)
callbackFunction to execute on state change
Returns
SoundRoutine coroutine handle
Deprecated:
Register Logic::on_change_to on the node instead. Scheduled for removal in the next release.

Definition at line 158 of file Tasks.cpp.

162{
163 auto& promise_ref = co_await GetAudioPromise {};
164
165 if (!logic_node) {
166 logic_node = std::make_shared<Nodes::Generator::Logic>(0.5);
167 }
168
169 logic_node->on_change_to(target_state,
170 [callback](const Nodes::NodeContext& /*ctx*/) {
171 callback();
172 });
173
174 while (true) {
175 if (promise_ref.should_terminate) {
176 break;
177 }
178
179 logic_node->process_sample(0.0);
180
181 co_await SampleDelay { 1 };
182 }
183}
PickCallback callback
Definition Picker.cpp:22
Templated awaitable for accessing a coroutine's promise object.

References callback.