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

◆ Toggle()

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

Coroutine that executes callback on any logic node state change.

Parameters
logic_nodeLogic node to monitor (creates default threshold node if null)
callbackFunction to execute on any state flip
Returns
SoundRoutine coroutine handle
Deprecated:
Register Logic::on_change on the node instead. Scheduled for removal in the next release.

Definition at line 185 of file Tasks.cpp.

188{
189 auto& promise_ref = co_await GetAudioPromise {};
190
191 if (!logic_node) {
192 logic_node = std::make_shared<Nodes::Generator::Logic>(0.5);
193 }
194
195 logic_node->on_change([callback](const Nodes::NodeContext& /*ctx*/) {
196 callback();
197 });
198
199 while (true) {
200 if (promise_ref.should_terminate) {
201 break;
202 }
203
204 logic_node->process_sample(0.0);
205
206 co_await SampleDelay { 1 };
207 }
208}
PickCallback callback
Definition Picker.cpp:22
Templated awaitable for accessing a coroutine's promise object.

References callback.