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

◆ extract_value()

double MayaFlux::Nodes::Input::OSCNode::extract_value ( const Core::InputValue &  value)
overrideprotectedvirtual

Extract a scalar value from an InputValue.

Parameters
valueThe input value to extract from
Returns
Scalar value for smoothing/output

Override in derived classes for specific input types. Default handles SCALAR and MIDI CC values.

Reimplemented from MayaFlux::Nodes::Input::InputNode.

Definition at line 10 of file OSCNode.cpp.

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}
glm::vec3 value
double held_value() const
The smoothed value the node currently holds.
std::optional< Core::InputValue::OSCMessage > m_last_osc_message
Definition OSCNode.hpp:149
@ OSC
Structured OSC message.
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

References MayaFlux::Nodes::Input::OSCConfig::argument_index, MayaFlux::Nodes::Input::OSCConfig::custom_extractor, MayaFlux::Nodes::Input::InputNode::held_value(), m_config, m_last_osc_message, MayaFlux::Nodes::Input::OSCConfig::normalize, MayaFlux::Core::InputValue::OSC, MayaFlux::Nodes::Input::OSCConfig::range_max, MayaFlux::Nodes::Input::OSCConfig::range_min, and value.

+ Here is the call graph for this function: