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

◆ extract_value()

double MayaFlux::Nodes::Input::TabletNode::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 13 of file TabletNode.cpp.

14{
16 return m_last_output;
17 }
18
19 const auto& vec = value.as_vector();
20 if (vec.size() < Core::TabletFrame::SLOT_COUNT) {
21 return m_last_output;
22 }
23
24 std::copy_n(vec.begin(), Core::TabletFrame::SLOT_COUNT, m_frame.begin());
25 m_frame_pending.store(true, std::memory_order_release);
26
27 if (m_config.state_bit) {
28 const auto state = static_cast<uint32_t>(m_frame[Core::TabletFrame::STATE]);
29 const auto bit = static_cast<uint32_t>(*m_config.state_bit);
30 return (state & bit) != 0U ? 1.0 : 0.0;
31 }
32
33 if (m_config.button_bit) {
34 const auto mask = static_cast<uint32_t>(m_frame[Core::TabletFrame::BUTTONS]);
35 return (mask & (1U << *m_config.button_bit)) != 0U ? 1.0 : 0.0;
36 }
37
40 }
41
42 return m_frame[m_config.slot];
43}
float value
std::array< double, Core::TabletFrame::SLOT_COUNT > m_frame
std::atomic< bool > m_frame_pending
double m_last_output
The most recent sample value generated by this oscillator.
Definition Node.hpp:425
@ VECTOR
Multiple float values (e.g., accelerometer xyz)
@ STATE
TabletState bitmask.
@ BUTTONS
Bit 0 barrel, bit 1 secondary barrel, bit 2 eraser.
static constexpr size_t SLOT_COUNT
double default_value
Initial output value.
Definition InputNode.hpp:71
std::optional< uint32_t > button_bit
When set, extract this BUTTONS bit.
std::optional< Core::TabletState > state_bit
When set, extract this STATE bit.
size_t slot
Frame slot driving the scalar.

References MayaFlux::Nodes::Input::TabletConfig::button_bit, MayaFlux::Core::TabletFrame::BUTTONS, MayaFlux::Nodes::Input::InputConfig::default_value, m_config, m_frame, m_frame_pending, MayaFlux::Nodes::Node::m_last_output, MayaFlux::Nodes::Input::TabletConfig::slot, MayaFlux::Core::TabletFrame::SLOT_COUNT, MayaFlux::Core::TabletFrame::STATE, MayaFlux::Nodes::Input::TabletConfig::state_bit, value, and MayaFlux::Core::InputValue::VECTOR.