MayaFlux 0.4.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{
12 if (value.type != Core::InputValue::Type::OSC) {
13 return m_last_output;
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 m_last_output;
26 }
27
28 if (m_config.argument_index >= osc.arguments.size()) {
29 return m_last_output;
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}
std::optional< Core::InputValue::OSCMessage > m_last_osc_message
Definition OSCNode.hpp:143
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:397
@ 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::Core::InputValue::as_osc(), MayaFlux::Nodes::Input::OSCConfig::custom_extractor, m_config, m_last_osc_message, MayaFlux::Nodes::Node::m_last_output, MayaFlux::Nodes::Input::OSCConfig::normalize, MayaFlux::Core::InputValue::OSC, MayaFlux::Nodes::Input::OSCConfig::range_max, MayaFlux::Nodes::Input::OSCConfig::range_min, and MayaFlux::Core::InputValue::type.

+ Here is the call graph for this function: