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

◆ notify_tick()

void MayaFlux::Nodes::Input::InputNode::notify_tick ( double  value)
overrideprotectedvirtual

Notify callbacks (minimal for InputNode)

InputNodes fire callbacks sparingly - the input event IS the notification. Override if you need per-sample callbacks (rare for input).

Implements MayaFlux::Nodes::Node.

Reimplemented in MayaFlux::Nodes::Input::MIDINode.

Definition at line 195 of file InputNode.cpp.

196{
197 update_context(value);
198 auto& ctx = get_last_context();
199
200 for (auto& callback : m_callbacks) {
201 callback(ctx);
202 }
203 for (auto& [callback, condition] : m_conditional_callbacks) {
204 if (condition(ctx)) {
205 callback(ctx);
206 }
207 }
208
209 for (auto& cb : m_input_callbacks) {
210 bool should_fire = false;
211
212 switch (cb.event_type) {
214 should_fire = true;
215 break;
216
218 double epsilon = cb.threshold.value_or(0.0001);
219 should_fire = std::abs(value - m_previous_value) > epsilon;
220 break;
221 }
222
224 should_fire = (m_previous_value < cb.threshold.value() && value >= cb.threshold.value());
225 break;
226
228 should_fire = (m_previous_value >= cb.threshold.value() && value < cb.threshold.value());
229 break;
230
232 auto [min, max] = cb.range.value();
233 bool in_range_now = (value >= min && value <= max);
234 should_fire = (!m_was_in_range && in_range_now);
235 m_was_in_range = in_range_now;
236 break;
237 }
238
240 auto [min, max] = cb.range.value();
241 bool in_range_now = (value >= min && value <= max);
242 should_fire = (m_was_in_range && !in_range_now);
243 m_was_in_range = in_range_now;
244 break;
245 }
246
248 should_fire = (m_previous_value < 0.5 && value >= 0.5);
249 break;
250
252 should_fire = (m_previous_value >= 0.5 && value < 0.5);
253 break;
254
256 should_fire = cb.condition && cb.condition.value()(ctx);
257 break;
258 }
259
260 if (should_fire) {
261 cb.callback(ctx);
262 }
263 }
264
265 m_previous_value = value;
266}
void update_context(double value) override
Update context after processing.
NodeContext & get_last_context() override
Retrieves the last created context object.
std::vector< InputCallback > m_input_callbacks
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
Definition Node.hpp:406
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
Definition Node.hpp:416
@ BUTTON_PRESS
Button went from 0.0 to 1.0.
@ THRESHOLD_FALLING
Value crossed threshold downward.
@ VALUE_CHANGE
Value changed from previous.
@ THRESHOLD_RISING
Value crossed threshold upward.
@ CONDITIONAL
User-provided condition.
@ RANGE_ENTER
Value entered specified range.
@ RANGE_EXIT
Value exited specified range.
@ BUTTON_RELEASE
Button went from 1.0 to 0.0.

References MayaFlux::Nodes::Input::BUTTON_PRESS, MayaFlux::Nodes::Input::BUTTON_RELEASE, MayaFlux::Nodes::Input::CONDITIONAL, get_last_context(), MayaFlux::Nodes::Node::m_callbacks, MayaFlux::Nodes::Node::m_conditional_callbacks, m_input_callbacks, m_previous_value, m_was_in_range, MayaFlux::Nodes::Input::RANGE_ENTER, MayaFlux::Nodes::Input::RANGE_EXIT, MayaFlux::Nodes::Input::THRESHOLD_FALLING, MayaFlux::Nodes::Input::THRESHOLD_RISING, MayaFlux::Nodes::Input::TICK, update_context(), and MayaFlux::Nodes::Input::VALUE_CHANGE.

Referenced by MayaFlux::Nodes::Input::MIDINode::notify_tick(), process_input(), and process_sample().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: