Skip to content

Commit

Permalink
fix #525
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jun 22, 2017
1 parent ea855af commit a73d167
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions base/plugins/iscore-plugin-curve/Curve/Segment/Sin/SinSegment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Curve/Palette/CurvePoint.hpp>
#include <Curve/Segment/CurveSegmentData.hpp>
#include <iscore/model/Identifier.hpp>
#include <ossia/detail/math.hpp>
#include <QDebug>
#include <QPoint>
#include <cmath>
Expand Down Expand Up @@ -101,10 +102,20 @@ class ISCORE_PLUGIN_CURVE_EXPORT PeriodicSegment final
}
}
}

template <typename Y>
std::function<Y(double, Y, Y)> makeFunction() const
{
return [=](double ratio, Y start, Y end) {
return
start + (end - start) / 2. *
(1. + ampl * PeriodicFunction{}(ossia::two_pi * ratio * freq));
};
}

double valueAt(double x) const override
{
ISCORE_TODO;
return -1;
return (1. + ampl * PeriodicFunction{}(ossia::two_pi * x * freq)) / 2.;
}

optional<double> verticalParameter() const override
Expand Down Expand Up @@ -133,15 +144,6 @@ class ISCORE_PLUGIN_CURVE_EXPORT PeriodicSegment final
return QVariant::fromValue(PeriodicSegmentData{freq, ampl});
}

template <typename Y>
std::function<Y(double, Y, Y)> makeFunction() const
{
return [=](double ratio, Y start, Y end) {
return
(end - start) / 2. *
(ampl * PeriodicFunction{}(6.28 * ratio * freq));
};
}
std::function<float(double, float, float)> makeFloatFunction() const override
{
return makeFunction<float>();
Expand Down

0 comments on commit a73d167

Please sign in to comment.