Deepnote Synthesizer Voice Library v1.0.0
A C++14 header-only library implementing the THX Deep Note effect
Loading...
Searching...
No Matches
bezier.hpp
Go to the documentation of this file.
1
34#pragma once
35
36#include "util/namedtype.hpp"
37
38namespace deepnote
39{
40
41namespace nt
42{
43using ControlPoint1 = NamedType<float, struct ControlPoint1Tag>;
44using ControlPoint2 = NamedType<float, struct ControlPoint2Tag>;
45}; // namespace nt
46
60{
61 BezierUnitShaper() = default;
62
63 explicit BezierUnitShaper(const nt::ControlPoint1 y2, const nt::ControlPoint2 y3)
64 : y2(y2.get())
65 , y3(y3.get())
66 {
67 }
68
69 BezierUnitShaper(const BezierUnitShaper &other) = default;
70 BezierUnitShaper &operator=(const BezierUnitShaper &other) = default;
71
77 float operator()(const float t) const
78 {
79 float y = (1 - t) * (1 - t) * y1 + 3 * (1 - t) * (1 - t) * t * y2 + 3 * (1 - t) * t * t * y3 + t * t * t * y4;
80
81 return y;
82 }
83
84 private:
85 float y1{0.f}; // start point
86 float y2{0.f}; // control point 1
87 float y3{0.f}; // control point 2
88 float y4{1.f}; // end point
89};
90
91} // namespace deepnote
Type-safe wrapper utilities for the Deep Note synthesizer.
Applies cubic Bezier curve shaping to unit input [0,1] -> [0,1].
Definition bezier.hpp:60
float operator()(const float t) const
Apply Bezier curve transformation to input value.
Definition bezier.hpp:77