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

◆ Gate()

MAYAFLUX_API Vruta::SoundRoutine MayaFlux::Kriya::Gate ( std::function< void()>  callback,
std::shared_ptr< Nodes::Generator::Logic >  logic_node,
bool  open = true 
)

Coroutine that executes callback continuously while logic node outputs true.

Parameters
callbackFunction to execute while condition is true
logic_nodeLogic node to monitor (creates default threshold node if null)
openWhether to subscribe to gate open (true) or close (false)
Returns
SoundRoutine coroutine handle
Deprecated:
Register Logic::while_true (or while_false) on the node instead. Scheduled for removal in the next release.

Definition at line 126 of file Tasks.cpp.

130{
131 auto& promise_ref = co_await GetAudioPromise {};
132
133 if (!logic_node) {
134 logic_node = std::make_shared<Nodes::Generator::Logic>(0.5);
135 }
136
137 if (open) {
138 logic_node->while_true([callback](const Nodes::NodeContext& /*ctx*/) {
139 callback();
140 });
141 } else {
142 logic_node->while_false([callback](const Nodes::NodeContext& /*ctx*/) {
143 callback();
144 });
145 }
146
147 while (true) {
148 if (promise_ref.should_terminate) {
149 break;
150 }
151
152 logic_node->process_sample(0.0);
153
154 co_await SampleDelay { 1 };
155 }
156}
PickCallback callback
Definition Picker.cpp:22
Templated awaitable for accessing a coroutine's promise object.

References callback.