fsh::stk
fantastic spatial holophonic synthesis toolkit
Loading...
Searching...
No Matches
EnvelopeFollower.h
1/***************************************************************************************************
2 ██████ █████ █████ █████
3 ███░░███ ░░███ ░░███ ░░███
4 ░███ ░░░ █████ ░███████ ██ ██ █████ ███████ ░███ █████
5 ███████ ███░░ ░███░░███ ░░ ░░ ███░░ ░░░███░ ░███░░███
6 ░░░███░ ░░█████ ░███ ░███ ░░█████ ░███ ░██████░
7 ░███ ░░░░███ ░███ ░███ ░░░░███ ░███ ███ ░███░░███
8 █████ ██████ ████ █████ ██ ██ ██████ ░░█████ ████ █████
9 ░░░░░ ░░░░░░ ░░░░ ░░░░░ ░░ ░░ ░░░░░░ ░░░░░ ░░░░ ░░░░░
10
11 fantastic spatial holophonic synthesis tool kit
12
13 copyright (c) fabian hummel
14 www.github.com/fshstk
15 www.fshstk.com
16
17 this file is part of the fantastic spatial holophonic synthesis toolkit (fsh::stk)
18 fsh::stk is free software: it is provided under the terms of the gnu general public license v3.0
19 www.gnu.org/licenses/gpl-3.0
20***************************************************************************************************/
21
22#pragma once
23
24namespace fsh::util
25{
44{
45public:
47 struct Params
48 {
51 };
52
54 auto getNextValue() -> double;
55
57 void setTargetValue(double);
58
60 void setSampleRate(double);
61
63 void setParams(const Params&);
64
67 void reset(double val = 0.0);
68
69private:
70 void calculateCoefficients();
71
72 Params _params;
73
74 double _coeffAttack = 1.0;
75 double _coeffRelease = 1.0;
76
77 double _currentValue = 0.0;
78 double _targetValue = 0.0;
79
80 double _sampleRate;
81};
82} // namespace fsh::util
Smoothed value tracking with separate attack/decay times.
Definition EnvelopeFollower.h:44
void setSampleRate(double)
Set the sample rate. This must be set before using the EnvelopeFollower.
Definition EnvelopeFollower.cpp:41
void setParams(const Params &)
Set the parameters. Will fall back on default values if not set.
Definition EnvelopeFollower.cpp:47
void setTargetValue(double)
Set the target.
Definition EnvelopeFollower.cpp:36
void reset(double val=0.0)
Reset both the current and target values to the specified value, or to zero if none is provided.
Definition EnvelopeFollower.cpp:53
auto getNextValue() -> double
Calculate the next value between the current value and the target.
Definition EnvelopeFollower.cpp:27
Parameters for EnvelopeFollower.
Definition EnvelopeFollower.h:48
double releaseTimeMilliseconds
release time in milliseconds
Definition EnvelopeFollower.h:50
double attackTimeMilliseconds
attack time in milliseconds
Definition EnvelopeFollower.h:49