2#include <ossia/dataflow/audio_port.hpp>
3#include <ossia/dataflow/data.hpp>
4#include <ossia/dataflow/geometry_port.hpp>
5#include <ossia/dataflow/midi_port.hpp>
6#include <ossia/dataflow/typed_value.hpp>
7#include <ossia/dataflow/value_port.hpp>
9#include <ossia/detail/nullable_variant.hpp>
10#include <ossia/network/base/parameter.hpp>
16 void operator()(value_port& p)
const { p.clear(); }
18 void operator()(midi_port& p)
const { p.messages.clear(); }
20 void operator()(audio_port& p)
const { p.set_channels(0); }
22 void operator()(geometry_port& p)
const { p.clear(); }
24 void operator()()
const { }
29 std::size_t operator()(
const value_delay_line& p)
const {
return p.data.
size(); }
31 std::size_t operator()(
const midi_delay_line& p)
const {
return p.messages.size(); }
33 std::size_t operator()(
const audio_delay_line& p)
const {
return p.samples.size(); }
35 std::size_t operator()(
const geometry_delay_line& p)
const
37 return p.geometries.size();
40 std::size_t operator()(
const ossia::monostate&)
const {
return 0; }
41 std::size_t operator()()
const {
return 0; }
46 void operator()(value_port& out, value_port& in)
48 in.add_port_values(std::move(out));
51 void operator()(audio_port& out, audio_port& in)
53 auto tmp = std::move(in.get());
54 in.get() = std::move(out.get());
55 out.get() = std::move(tmp);
58 void operator()(midi_port& out, midi_port& in)
60 auto tmp = std::move(in.messages);
61 in.messages = std::move(out.messages);
62 out.messages = std::move(tmp);
65 void operator()(geometry_port& out, geometry_port& in)
69 in.geometry = out.geometry;
71 in.transform = out.transform;
81 operator()(
const value_vector<std::pair<ossia::typed_value, int>>& out, value_port& in)
85 in.add_local_value(val.first);
87 void operator()(
const value_vector<ossia::typed_value>& out, value_port& in)
91 in.add_local_value(val);
94 void operator()(
const value_port& out, value_port& in)
97 in.add_port_values(out);
100 void operator()(
const net::parameter_base& param, value_port& in)
103 in.add_global_value(param, param.value());
107 const net::parameter_base& param,
const value_vector<ossia::value>& vec,
111 in.add_global_values(param, vec);
114 void operator()(
const value_port& out, value_delay_line& in)
116#if !defined(OSSIA_FREESTANDING)
118 value_vector<ossia::typed_value> vec;
119 vec.reserve(out.get_data().size());
120 for(
const ossia::timed_value& val : out.get_data())
122 vec.emplace_back(val, out.index, out.type);
124 in.data.push_back(std::move(vec));
129 void operator()(
const audio_port& out, audio_delay_line& in)
132 in.samples.push_back(out.get());
135 void operator()(
const audio_port& out, audio_port& in)
138 mix(out.get(), in.get());
142 void operator()(
const midi_port& out, midi_port& in)
145 operator()(out.messages, in);
148 void operator()(
const value_vector<libremidi::ump>& out, midi_port& in)
151 for(
const auto& data : out)
152 in.messages.push_back(data);
155 void operator()(
const midi_port& out, midi_delay_line& in)
158 in.messages.push_back(out.messages);
162 void operator()(
const geometry_port& out, geometry_port& in)
166 in.geometry = out.geometry;
168 in.transform = out.transform;
169 in.flags = out.flags;
172 void operator()(
const geometry_spec& out, geometry_port& in)
178 void operator()(
const geometry_port& out, geometry_delay_line& in)
182 in.geometries.push_back(out.geometry);
188 const std::size_t pos;
190 template <
typename T,
typename U>
191 void operator()(
const T&,
const U&)
const
195 void operator()(
const value_delay_line& out, value_port& in)
197 if(pos < out.data.size())
199 copy_data{}(out.data[pos], in);
203 void operator()(
const audio_delay_line& out, audio_port& in)
205 if(pos < out.samples.size())
207 mix(out.samples[pos], in.get());
211 void operator()(
const midi_delay_line& out, midi_port& in)
213 if(pos < out.messages.size())
215 copy_data{}(out.messages[pos], in);
218 void operator()(
const geometry_delay_line& out, geometry_port& in)
220 if(pos < out.geometries.size())
222 copy_data{}(out.geometries[pos], in);