Anklang
0.3.0-460-gc4ef46ba
ASE — Anklang Sound Engine (C++)
« « « Anklang Documentation
Loading...
Searching...
No Matches
devices
blepsynth
linearsmooth.hh
Go to the documentation of this file.
1
// This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
2
#ifndef __ASE_DEVICES_LINEAR_SMOOTH_HH__
3
#define __ASE_DEVICES_LINEAR_SMOOTH_HH__
4
5
/* from liquidsfz utils */
6
7
#include <math.h>
8
9
#include <
string
>
10
11
namespace
Ase
{
12
13
class
LinearSmooth
14
{
15
float
value_ = 0;
16
float
linear_value_ = 0;
17
float
linear_step_ = 0;
18
uint
total_steps_ = 1;
19
uint
steps_ = 0;
20
public
:
21
void
22
reset (
uint
rate,
float
time
)
23
{
24
total_steps_ =
std::max<int>
(rate *
time
, 1);
25
}
26
void
27
set (
float
new_value,
bool
now =
false
)
28
{
29
if
(now)
30
{
31
steps_ = 0;
32
value_ = new_value;
33
}
34
else
if
(new_value != value_)
35
{
36
if
(!steps_)
37
linear_value_ = value_;
38
39
linear_step_ = (new_value - linear_value_) / total_steps_;
40
steps_ = total_steps_;
41
value_ = new_value;
42
}
43
}
44
float
45
get_next()
46
{
47
if
(!steps_)
48
return
value_;
49
else
50
{
51
steps_--;
52
linear_value_ += linear_step_;
53
return
linear_value_;
54
}
55
}
56
bool
57
is_constant()
58
{
59
return
steps_ == 0;
60
}
61
};
62
63
}
64
65
#endif
/* __ASE_DEVICES_LINEAR_SMOOTH_HH__ */
std::atomic
Ase::LinearSmooth
Definition
linearsmooth.hh:14
Ase
The Anklang C++ API namespace.
Definition
api.hh:9
Ase::uint
uint32_t uint
Provide 'uint' as convenience type.
Definition
cxxaux.hh:18
string
time
time
« « « Anklang Documentation