2#include <ossia/audio/audio_parameter.hpp>
3#include <ossia/dataflow/audio_lock.hpp>
4#include <ossia/dataflow/data_copy.hpp>
5#include <ossia/dataflow/execution/local_state_execution_policy.hpp>
6#include <ossia/dataflow/execution_state.hpp>
7#include <ossia/protocols/midi/detail/midi_impl.hpp>
8#include <ossia/protocols/midi/midi_node.hpp>
12struct local_pull_visitor
14 local_state_execution_policy& st;
16 bool operator()(value_port& val)
const
18 OSSIA_EXEC_STATE_LOCK_READ(st);
19 auto it = st.m_valueState.find(addr);
20 if(it != st.m_valueState.end() && !it->second.empty())
22 copy_data{}(it->second, val);
28 bool operator()(audio_port& val)
const
30#if defined(OSSIA_PROTOCOL_AUDIO)
31 OSSIA_EXEC_STATE_LOCK_READ(st);
32 auto it = st.m_audioState.find(
static_cast<ossia::audio_parameter*
>(addr));
33 if(it != st.m_audioState.end() && !it->second.empty())
35 copy_data{}(it->second, val);
42 bool operator()(midi_port& val)
const
44#if defined(OSSIA_PROTOCOL_MIDI)
45 OSSIA_EXEC_STATE_LOCK_READ(st);
46 auto it = st.m_midiState.find(addr);
47 if(it != st.m_midiState.end() && !it->second.empty())
49 copy_data{}(it->second, val);
56 [[noreturn]]
bool operator()(geometry_port& val)
const
62 bool operator()()
const {
return false; }
65struct global_pull_visitor
67 ossia::execution_state& state;
68 const net::parameter_base& out;
69 void operator()(value_port& val)
const
73 copy_data{}(out, val);
77 auto it = state.m_receivedValues.find(
const_cast<net::parameter_base*
>(&out));
78 if(it != state.m_receivedValues.end())
80 copy_data{}(*it->first, it->second, val);
85 void operator()(audio_port& val)
const
87#if defined(OSSIA_PROTOCOL_AUDIO)
89 auto aa =
dynamic_cast<const audio_parameter*
>(&out);
92 auto aa =
static_cast<const audio_parameter*
>(&out);
94 aa->clone_value(val.get());
98 void operator()(midi_port& val)
const
100#if defined(OSSIA_PROTOCOL_MIDI)
101 auto& node = out.get_node();
102 auto& dev = node.get_device();
103 auto& proto = dev.get_protocol();
108 auto midi =
dynamic_cast<ossia::net::midi::midi_protocol*
>(&proto);
111 auto midi =
static_cast<ossia::net::midi::midi_protocol*
>(&proto);
114 auto it = state.m_receivedMidi.find(midi);
115 if(it != state.m_receivedMidi.end())
117 for(
const libremidi::ump& v : it->second.messages)
119 val.messages.push_back(v);
125 [[noreturn]]
void operator()(geometry_port& val)
const { assert(
false); }
127 void operator()()
const { }
130struct global_pull_node_visitor
132 ossia::execution_state& state;
133 const net::node_base& out;
134 void operator()(value_port& val)
const { val.write_value(ossia::net::to_map(out), 0); }
136 void operator()(audio_port& val)
const
141 void operator()(midi_port& val)
const
143#if defined(OSSIA_PROTOCOL_MIDI)
145 auto& dev = node.get_device();
146 auto& proto = dev.get_protocol();
151 auto midi =
dynamic_cast<ossia::net::midi::midi_protocol*
>(&proto);
154 auto midi =
static_cast<ossia::net::midi::midi_protocol*
>(&proto);
158 if(node.get_parent() == &dev.get_root_node())
161 channel =
static_cast<const ossia::net::midi::channel_node&
>(node).channel;
164 auto it = state.m_receivedMidi.find(midi);
165 if(it != state.m_receivedMidi.end())
169 for(
const libremidi::ump& v : it->second.messages)
171 val.messages.push_back(v);
176 for(
const libremidi::ump& v : it->second.messages)
178 if(v.get_channel() == channel)
179 val.messages.push_back(v);
186 [[noreturn]]
void operator()(geometry_port& val)
const { assert(
false); }
188 void operator()()
const { }
The parameter_base class.
Definition ossia/network/base/parameter.hpp:48