2 #include <Process/Dataflow/Port.hpp>
3 #include <Process/ExecutionContext.hpp>
4 #include <Process/ExecutionSetup.hpp>
5 #include <Process/ExecutionTransaction.hpp>
6 #include <Process/Process.hpp>
8 #include <Curve/CurveConversion.hpp>
10 #include <Scenario/Document/Interval/IntervalModel.hpp>
11 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentModel.hpp>
12 #include <Scenario/Document/Tempo/TempoProcess.hpp>
14 #include <ossia/dataflow/graph/graph_interface.hpp>
15 #include <ossia/dataflow/graph_edge.hpp>
16 #include <ossia/dataflow/graph_node.hpp>
17 #include <ossia/dataflow/port.hpp>
18 #include <ossia/detail/pod_vector.hpp>
19 #include <ossia/editor/curve/curve.hpp>
20 #include <ossia/editor/scenario/time_interval.hpp>
21 #include <ossia/editor/scenario/time_process.hpp>
26 inline std::pair<std::optional<ossia::tempo_curve>, Scenario::TempoProcess*>
30 if(
auto proc = itv.tempoCurve())
32 auto& curve = proc->curve();
34 const auto defaultdur = itv.duration.defaultDuration().msec();
35 auto scale_x = [&ctx, defaultdur](
double val) -> int64_t {
36 return ctx.
time(TimeVal::fromMsecs(val * defaultdur)).impl;
38 auto scale_y = [=](
double val) ->
double {
40 return val * (TempoProcess::max - TempoProcess::min) + TempoProcess::min;
45 auto segt_data = curve.sortedSegments();
46 if(segt_data.size() != 0)
48 t = std::move(*Engine::score_to_ossia::curve<int64_t, double>(
49 scale_x, scale_y, segt_data, {}));
52 return {std::optional<ossia::tempo_curve>{std::move(t)}, proc};
59 inline ossia::time_signature_map
62 ossia::time_signature_map ret;
63 for(
const auto& [time, sig] : itv.timeSignatureMap())
65 ret[ctx.
time(time)] = sig;
72 ossia::pod_vector<std::size_t> propagated_outlets;
73 for(std::size_t i = 0; i < outlets.size(); i++)
75 if(
auto o = qobject_cast<Process::AudioOutlet*>(outlets[i]))
77 propagated_outlets.push_back(i);
79 return propagated_outlets;
82 inline void connectPropagated(
83 const ossia::node_ptr& process_node,
const ossia::node_ptr& interval_node,
84 ossia::graph_interface& g,
85 const ossia::pod_vector<std::size_t>& propagated_outlets) noexcept
87 const auto& outs = process_node->root_outputs();
88 for(std::size_t propagated : propagated_outlets)
90 if(propagated >= outs.size())
93 if(outs[propagated]->which() == ossia::audio_port::which)
95 auto cable = g.allocate_edge(
96 ossia::immediate_glutton_connection{}, outs[propagated],
97 interval_node->root_inputs()[0], process_node, interval_node);
103 inline void updatePropagated(
104 const ossia::node_ptr& process_node,
const ossia::node_ptr& interval_node,
105 ossia::graph_interface& g, std::size_t port_idx,
bool is_propagated) noexcept
107 const auto& outs = process_node->root_outputs();
109 if(port_idx >= outs.size())
112 const ossia::outlet& outlet = *outs[port_idx];
114 if(!outlet.target<ossia::audio_port>())
120 for(
const ossia::graph_edge* edge : outlet.targets)
122 if(edge->in_node == interval_node)
126 auto cable = g.allocate_edge(
127 ossia::immediate_glutton_connection{}, outs[port_idx],
128 interval_node->root_inputs()[0], process_node, interval_node);
133 for(ossia::graph_edge* edge : outlet.targets)
135 if(edge->in_node == interval_node)
147 std::shared_ptr<ossia::time_interval> cst;
148 ossia::time_interval* cst_ptr{};
149 std::weak_ptr<ossia::time_process> oproc_weak;
150 std::weak_ptr<ossia::graph_interface> g_weak;
151 ossia::pod_vector<std::size_t> propagated_outlets;
153 void operator()()
const noexcept
155 auto oproc = oproc_weak.lock();
159 auto g = g_weak.lock();
163 cst_ptr->add_time_process(oproc);
167 connectPropagated(oproc->node, cst_ptr->node, *g, propagated_outlets);
175 std::weak_ptr<ossia::graph_node> cst_node_weak;
176 std::weak_ptr<ossia::time_process> oproc_weak;
177 std::weak_ptr<ossia::graph_interface> g_weak;
180 void operator()(
bool propagate)
const noexcept
185 = std::distance(proc.outlets().begin(), ossia::find(proc.outlets(), outlet));
188 [cst_node_weak = this->cst_node_weak, g_weak = this->g_weak,
189 oproc_weak = this->oproc_weak, port_index, propagate] {
190 const auto g = g_weak.lock();
194 const auto cst_node = cst_node_weak.lock();
198 const auto oproc = oproc_weak.lock();
202 const auto& proc_node = oproc->node;
204 updatePropagated(proc_node, cst_node, *g, port_index, propagate);
209 template <
typename T>
213 std::weak_ptr<ossia::graph_node> fw_node;
216 std::weak_ptr<ossia::time_process> oproc_weak;
218 std::weak_ptr<ossia::graph_interface> g_weak;
220 void operator()()
const noexcept
224 if(
auto o = qobject_cast<Process::AudioOutlet*>(outlet))
227 o, &Process::AudioOutlet::propagateChanged, &component,
nullptr);
229 o, &Process::AudioOutlet::propagateChanged, &component,
231 component.system(), proc, fw_node, oproc_weak, g_weak, outlet});
239 std::weak_ptr<ossia::graph_node> cst_node_weak;
240 std::weak_ptr<ossia::time_process> oproc_weak;
241 std::weak_ptr<ossia::graph_interface> g_weak;
245 const ossia::node_ptr& old_node,
const ossia::node_ptr& new_node,
250 [cst_node_weak = this->cst_node_weak, g_weak = this->g_weak,
251 propagated = propagatedOutlets(proc.outlets()), old_node, new_node] {
252 auto cst_node = cst_node_weak.lock();
255 auto g = g_weak.lock();
262 ossia::graph_node& n = *old_node;
263 for(auto& outlet : n.root_outputs())
265 auto targets = outlet->targets;
266 for(auto e : targets)
268 if(e->in_node.get() == cst_node.get())
279 connectPropagated(new_node, cst_node, *g, propagated);
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
Definition: IntervalModel.hpp:50
Components used for the execution of a score.
Definition: ProcessComponent.cpp:12
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: IntervalExecutionHelpers.hpp:145
Definition: ExecutionContext.hpp:76
ExecutionCommandQueue & executionQueue
Definition: ExecutionContext.hpp:91
Execution::time_function time
Definition: ExecutionContext.hpp:87
Definition: IntervalExecutionHelpers.hpp:238
Definition: IntervalExecutionHelpers.hpp:172
Definition: IntervalExecutionHelpers.hpp:211
Definition: ExecutionTransaction.hpp:18
Definition: PortForward.hpp:27