2#include <ossia/audio/audio_parameter.hpp>
3#include <ossia/dataflow/data_copy.hpp>
4#include <ossia/dataflow/graph_edge.hpp>
5#include <ossia/dataflow/graph_node.hpp>
6#include <ossia/dataflow/port.hpp>
8#include <ossia/network/common/path.hpp>
10#include <boost/range/algorithm/lexicographical_compare.hpp>
17 const std::vector<graph_node*>& node_order;
18 const execution_state& st;
20 bool compare(
const graph_node* lhs,
const graph_node* rhs)
const
22 for(std::size_t i = 0, N = node_order.size(); i < N; i++)
24 if(node_order[i] == lhs)
26 else if(node_order[i] == rhs)
32 std::runtime_error,
"lhs and rhs have to be found");
35 bool operator()(
const graph_node* lhs,
const graph_node* rhs)
const
40 bool c1 = lhs->has_port_inputs();
41 bool c2 = rhs->has_port_inputs();
49 return compare(lhs, rhs);
51 bool l1 = lhs->has_local_inputs(st);
52 bool l2 = rhs->has_local_inputs(st);
59 return compare(lhs, rhs);
61 bool g1 = lhs->has_global_inputs();
62 bool g2 = rhs->has_global_inputs();
68 return compare(lhs, rhs);
70 return compare(lhs, rhs);
74struct init_node_visitor
77 const graph_edge& edge;
80 static void copy(
const delay_line_type& out, std::size_t pos, inlet& in)
82 const auto w = out.which();
83 if(w.to_std_index() == in.which() && w.valid())
87 case delay_line_type::index_of<ossia::audio_delay_line>().index():
89 *
reinterpret_cast<const ossia::audio_delay_line*
>(out.target()),
90 in.cast<ossia::audio_port>());
92 case delay_line_type::index_of<ossia::midi_delay_line>().index():
94 *
reinterpret_cast<const ossia::midi_delay_line*
>(out.target()),
95 in.cast<ossia::midi_port>());
97 case delay_line_type::index_of<ossia::value_delay_line>().index():
99 *
reinterpret_cast<const ossia::value_delay_line*
>(out.target()),
100 in.cast<ossia::value_port>());
102 case delay_line_type::index_of<ossia::geometry_delay_line>().index():
104 *
reinterpret_cast<const ossia::geometry_delay_line*
>(out.target()),
105 in.cast<ossia::geometry_port>());
111 static void move(outlet& out, inlet& in)
113 const auto w = out.which();
118 case ossia::audio_port::which:
119 move_data{}(out.cast<ossia::audio_port>(), in.cast<ossia::audio_port>());
121 case ossia::midi_port::which:
122 move_data{}(out.cast<ossia::midi_port>(), in.cast<ossia::midi_port>());
124 case ossia::value_port::which:
125 move_data{}(out.cast<ossia::value_port>(), in.cast<ossia::value_port>());
127 case ossia::geometry_port::which:
128 move_data{}(out.cast<ossia::geometry_port>(), in.cast<ossia::geometry_port>());
133 static void copy(outlet& out, inlet& in)
135 if(out.cables().size() == 1 && in.cables().size() == 1 && !out.address
142 const auto w = out.which();
147 case ossia::audio_port::which:
148 copy_data{}(out.cast<ossia::audio_port>(), in.cast<ossia::audio_port>());
150 case ossia::midi_port::which:
151 copy_data{}(out.cast<ossia::midi_port>(), in.cast<ossia::midi_port>());
153 case ossia::value_port::which:
154 copy_data{}(out.cast<ossia::value_port>(), in.cast<ossia::value_port>());
156 case ossia::geometry_port::which:
158 out.cast<ossia::geometry_port>(), in.cast<ossia::geometry_port>());
165 bool operator()(immediate_glutton_connection)
const
167 if(edge.out_node->enabled())
179 bool operator()(immediate_strict_connection)
const
187 bool operator()(delayed_glutton_connection& con)
const
191 copy(con.buffer, con.pos, in);
196 bool operator()(delayed_strict_connection& con)
const
198 copy(con.buffer, con.pos, in);
203 bool operator()(dependency_connection)
const {
return true; }
205 bool operator()()
const {
return true; }
207struct init_must_copy_visitor
209 const graph_edge& edge;
211 bool operator()(
const immediate_glutton_connection&)
const
213 return !edge.out_node->enabled();
216 bool operator()(
const immediate_strict_connection&)
const {
return false; }
218 bool operator()(
const delayed_glutton_connection&)
const {
return false; }
220 bool operator()(
const delayed_strict_connection&)
const {
return false; }
222 bool operator()(
const dependency_connection&)
const {
return true; }
224 bool operator()()
const {
return true; }
231 bool operator()(
const immediate_glutton_connection&)
const
233 return !edge.in_node->enabled();
235 bool operator()(
const immediate_strict_connection& con)
const
237 using rs = immediate_strict_connection::required_sides_t;
238 switch(con.required_sides)
252 bool operator()(delayed_glutton_connection& con)
const
255 const auto con_w = con.buffer.which();
256 const auto out_w = out.which();
257 if(con_w.to_std_index() == out_w)
259 switch(con_w.index())
261 case delay_line_type::index_of<ossia::audio_delay_line>().index():
263 out.cast<ossia::audio_port>(),
264 *
reinterpret_cast<ossia::audio_delay_line*
>(con.buffer.target()));
266 case delay_line_type::index_of<ossia::midi_delay_line>().index():
268 out.cast<ossia::midi_port>(),
269 *
reinterpret_cast<ossia::midi_delay_line*
>(con.buffer.target()));
271 case delay_line_type::index_of<ossia::value_delay_line>().index():
273 out.cast<ossia::value_port>(),
274 *
reinterpret_cast<ossia::value_delay_line*
>(con.buffer.target()));
280 bool operator()(delayed_strict_connection& con)
const
283 const auto con_w = con.buffer.which();
284 const auto out_w = out.which();
285 if(con_w.to_std_index() == out_w)
287 switch(con_w.index())
289 case delay_line_type::index_of<ossia::audio_delay_line>().index():
291 out.cast<ossia::audio_port>(),
292 *
reinterpret_cast<ossia::audio_delay_line*
>(con.buffer.target()));
294 case delay_line_type::index_of<ossia::midi_delay_line>().index():
296 out.cast<ossia::midi_port>(),
297 *
reinterpret_cast<ossia::midi_delay_line*
>(con.buffer.target()));
299 case delay_line_type::index_of<ossia::value_delay_line>().index():
301 out.cast<ossia::value_port>(),
302 *
reinterpret_cast<ossia::value_delay_line*
>(con.buffer.target()));
308 bool operator()(
const dependency_connection&)
const {
return false; }
309 bool operator()()
const {
return false; }