2 #include <Process/Dataflow/Port.hpp>
3 #include <Process/Dataflow/PortFactory.hpp>
4 #include <Process/Process.hpp>
6 #include <Crousti/Concepts.hpp>
7 #include <Media/Sound/Drop/SoundDrop.hpp>
9 #include <avnd/binding/ossia/port_base.hpp>
10 #include <avnd/concepts/all.hpp>
12 #include <Gfx/TexturePort.hpp>
17 template <
typename Info>
28 #if !defined(__APPLE__)
29 constexpr
auto name = avnd::get_name<T>();
30 obj->setName(fromStringView(name));
31 if constexpr(avnd::has_description<T>)
32 obj->setDescription(fromStringView(avnd::get_description<T>()));
34 auto name = avnd::get_name<T>();
35 obj->setName(fromStringView(name));
36 if constexpr(avnd::has_description<T>)
37 obj->setDescription(fromStringView(avnd::get_description<T>()));
41 template <std::
size_t N,
typename T>
42 inline void setupNewPort(
const avnd::field_reflection<N, T>& spec,
Process::Port* obj)
53 template <
typename Node>
60 void operator()(
const oscr::ossia_value_port
auto& in,
auto idx)
66 void operator()(
const oscr::ossia_audio_port
auto& in,
auto idx)
72 void operator()(
const oscr::ossia_midi_port
auto& in,
auto idx)
79 void operator()(
const avnd::audio_port
auto& in,
auto idx)
85 void operator()(
const avnd::midi_port
auto& in,
auto idx)
92 static QString toFilters(
const QSet<QString>& exts)
95 for(
const auto& s : exts)
102 res.resize(res.size() - 1);
106 template <
typename P>
107 static QString getFilters(P& p)
109 if constexpr(requires { P::filters(); })
111 using filter = decltype(P::filters());
112 if constexpr(requires { filter::sound; } || requires { filter::audio; })
114 return QString{
"Sound files (%1)"}.arg(
117 else if constexpr(requires { filter::video; })
120 QSet<QString> files = {
"mkv",
"mov",
"mp4",
"h264",
"avi",
"hap",
"mpg",
121 "mpeg",
"imf",
"mxf",
"mts",
"m2ts",
"mj2",
"webm"};
122 return QString{
"Videos (%1)"}.arg(toFilters(files));
124 else if constexpr(requires { filter::image; })
127 return QString{
"Images (*.png *.jpg *.jpeg *.gif *.bmp *.tiff)"};
129 else if constexpr(requires { filter::midi; })
131 return "MIDI (*.mid)";
133 else if constexpr(avnd::string_ish<filter>)
135 static constexpr
auto text_filters = P::filters();
136 return fromStringView(P::filters());
143 else if constexpr(requires { P::extensions(); })
145 static constexpr
auto text_filters = P::extensions();
146 return fromStringView(text_filters);
154 template <
typename T>
155 requires avnd::soundfile_port<T>
156 void operator()(
const T& in,
auto idx)
158 static constexpr
auto name = avnd::get_name<T>();
159 Process::FileChooserBase* p{};
160 if constexpr(requires { T::waveform; })
162 p =
new Process::AudioFileChooser{
163 "", getFilters(in), QString::fromUtf8(name.data(), name.size()),
168 p =
new Process::FileChooser{
169 "", getFilters(in), QString::fromUtf8(name.data(), name.size()),
176 if constexpr(avnd::tag_file_watch<T>)
178 p->enableFileWatch();
182 template <
typename T>
183 requires avnd::midifile_port<T> || avnd::raw_file_port<T>
184 void operator()(
const T& in,
auto idx)
186 static constexpr
auto name = avnd::get_name<T>();
188 auto p =
new Process::FileChooser{
189 "", getFilters(in), QString::fromUtf8(name.data(), name.size()),
194 if constexpr(avnd::tag_file_watch<T>)
196 p->enableFileWatch();
200 template <avnd::dynamic_ports_port T, std::
size_t N>
201 void operator()(
const T& in, avnd::field_index<N> i)
203 using port_type =
typename decltype(in.ports)::value_type;
208 template <avnd::parameter T, std::
size_t N>
209 requires(!oscr::ossia_port<T>)
210 void operator()(
const T& in, avnd::field_index<N>)
212 if constexpr(avnd::has_widget<T> || avnd::curve_port<T>)
214 auto p = oscr::make_control_in<Node, T>(
216 if constexpr(!std::is_same_v<std::decay_t<decltype(p)>, std::nullptr_t>)
224 setupNewPort(in, vp);
231 setupNewPort(in, vp);
238 void operator()(
const avnd::texture_port
auto& in,
auto idx)
244 void operator()(
const avnd::geometry_port
auto& in,
auto idx)
252 template <std::
size_t Idx, avnd::message T>
253 void operator()(
const avnd::field_reflection<Idx, T>& in,
auto dummy)
260 template <std::
size_t Idx, avnd::unreflectable_message<Node> T>
261 void operator()(
const avnd::field_reflection<Idx, T>& in,
auto dummy)
268 void operator()(
const auto& ctrl,
auto idx)
271 qDebug() << fromStringView(avnd::get_name(ctrl)) <<
"unhandled";
275 template <
typename Node>
282 void operator()(
const oscr::ossia_value_port
auto& out,
auto idx)
285 setupNewPort(out, p);
288 void operator()(
const oscr::ossia_audio_port
auto& out,
auto idx)
291 setupNewPort(out, p);
294 void operator()(
const oscr::ossia_midi_port
auto& out,
auto idx)
297 setupNewPort(out, p);
301 template <avnd::dynamic_ports_port T, std::
size_t N>
302 void operator()(
const T& in, avnd::field_index<N> i)
304 using port_type =
typename decltype(in.ports)::value_type;
309 void operator()(
const avnd::audio_port
auto& out,
auto idx)
312 setupNewPort(out, p);
314 p->setPropagate(
true);
318 void operator()(
const avnd::midi_port
auto& out,
auto idx)
321 setupNewPort(out, p);
325 template <avnd::parameter T, std::
size_t N>
326 requires(!oscr::ossia_port<T>)
327 void operator()(
const T& out, avnd::field_index<N>)
329 if constexpr(avnd::has_widget<T>)
331 if(
auto p = oscr::make_control_out<T>(
341 setupNewPort(out, vp);
348 setupNewPort(out, vp);
355 void operator()(
const avnd::texture_port
auto& out,
auto idx)
358 setupNewPort(out, p);
361 void operator()(
const avnd::geometry_port
auto& out,
auto idx)
364 setupNewPort(out, p);
369 void operator()(
const avnd::curve_port
auto& out,
auto idx)
372 setupNewPort(out, p);
376 template <avnd::callback T, std::
size_t N>
377 void operator()(
const T& out, avnd::field_index<N>)
379 if constexpr(avnd::control<T>)
381 if(
auto p = oscr::make_control_out<T>(
391 setupNewPort(out, vp);
395 else if constexpr(requires { T::control; })
399 setupNewPort(out, p);
405 setupNewPort(out, p);
411 void operator()(
const auto& ctrl,
auto idx)
413 qDebug() << fromStringView(avnd::get_name(ctrl)) <<
"unhandled";
Definition: TexturePort.hpp:121
Definition: TexturePort.hpp:144
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
The id_base_t class.
Definition: Identifier.hpp:57
Definition: Factories.hpp:19
Definition: PortForward.hpp:23
Definition: PortForward.hpp:27
Definition: ProcessModelPortInit.hpp:55
Definition: ProcessModelPortInit.hpp:277