MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
OSCNode.cpp
Go to the documentation of this file.
1#include "OSCNode.hpp"
2
4
6 : m_config(std::move(config))
7{
8}
9
11{
13 return held_value();
14 }
15
16 const auto& osc = value.as_osc();
18
19 if (m_config.custom_extractor && !osc.arguments.empty()) {
20 size_t idx = std::min(m_config.argument_index, osc.arguments.size() - 1);
21 return m_config.custom_extractor(osc.arguments[idx]);
22 }
23
24 if (osc.arguments.empty()) {
25 return held_value();
26 }
27
28 if (m_config.argument_index >= osc.arguments.size()) {
29 return held_value();
30 }
31
32 double raw = static_cast<double>(
33 osc.get_float(m_config.argument_index).value_or(static_cast<float>(osc.get_int(m_config.argument_index).value_or(0))));
34
37 raw = std::clamp(raw, 0.0, 1.0);
38 }
39
40 return raw;
41}
42
50
51} // namespace MayaFlux::Nodes::Input
glm::vec3 value
void fire(NodeContext &ctx) const
Calls every entry whose condition, if any, holds.
Definition NodeUtils.cpp:68
NodeContext & get_last_context() override
Retrieves the last created context object.
void notify_tick(double value) override
Fires the hooks for one delivered input.
double held_value() const
The smoothed value the node currently holds.
std::optional< Core::InputValue::OSCMessage > m_last_osc_message
Definition OSCNode.hpp:149
OSCNode(OSCConfig config={})
Definition OSCNode.cpp:5
double extract_value(const Core::InputValue &value) override
Extract a scalar value from an InputValue.
Definition OSCNode.cpp:10
void notify_tick(double value) override
Fires the hooks for one delivered input.
Definition OSCNode.cpp:43
@ OSC
Structured OSC message.
Generic input value container.
double range_min
Expected input minimum (for normalization)
Definition OSCNode.hpp:19
bool normalize
Map [range_min, range_max] to [0.0, 1.0].
Definition OSCNode.hpp:21
size_t argument_index
Which argument to extract (0-based)
Definition OSCNode.hpp:17
double range_max
Expected input maximum (for normalization)
Definition OSCNode.hpp:20
std::function< double(const Core::InputValue::OSCArg &)> custom_extractor
Definition OSCNode.hpp:23
Configuration for OSC input node argument extraction.
Definition OSCNode.hpp:16