2 #include <Curve/Segment/Linear/LinearSegment.hpp>
3 #include <Curve/Segment/Power/PowerSegment.hpp>
5 #include <ossia/editor/curve/curve.hpp>
9 namespace score_to_ossia
12 template <
typename Y_T>
18 static const constexpr
auto fun = &Curve::SegmentModel::makeIntFunction;
24 static const constexpr
auto fun = &Curve::SegmentModel::makeFloatFunction;
31 static const constexpr
auto fun = &Curve::SegmentModel::makeDoubleFunction;
35 typename X_T,
typename Y_T,
typename XScaleFun,
typename YScaleFun,
37 std::shared_ptr<ossia::curve<X_T, Y_T>> curve(
38 XScaleFun scale_x, YScaleFun scale_y,
const Segments& segments,
39 const std::optional<ossia::destination>& tween)
41 auto curve = std::make_shared<ossia::curve<X_T, Y_T>>();
42 curve->reserve(segments.size() + 1);
44 auto start = segments[0]->start();
47 curve->set_x0(scale_x(start.x()));
48 curve->set_y0(scale_y(start.y()));
51 for(
const auto& score_segment : segments)
53 auto end = score_segment->end();
55 (score_segment->*CurveTraits<Y_T>::fun)(), scale_x(end.x()), scale_y(end.y()));
60 curve->set_y0_destination(*tween);
67 template <
typename Segments>
68 ossia::curve<double, float>
69 floatCurve(
const Segments& segments,
const std::optional<ossia::destination>& tween)
71 ossia::curve<double, float> curve;
73 auto start = segments[0]->start();
76 curve.set_x0(start.x());
77 curve.set_y0(start.y());
80 for(
const auto& score_segment : segments)
82 auto end = score_segment->end();
83 curve.add_point((score_segment->*CurveTraits<float>::fun)(), end.x(), end.y());
88 curve.set_y0_destination(*tween);
Link of score with the OSSIA API execution engine.
Definition: CurveConversion.hpp:8
Definition: CurveConversion.hpp:13