Anklang-0.3.0.dev967+g08f67ae3
anklang-0.3.0.dev967+g08f67ae3
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
#pragma once
3
4
/* from liquidsfz utils */
5
6
#include <math.h>
7
8
#include <
string
>
9
10
namespace
Ase
{
11
12
class
LinearSmooth
13
{
14
float
value_ = 0;
15
float
linear_value_ = 0;
16
float
linear_step_ = 0;
17
uint
total_steps_ = 1;
18
uint
steps_ = 0;
19
public
:
20
void
21
reset (
uint
rate,
float
time
)
22
{
23
total_steps_ =
std::max<int>
(rate *
time
, 1);
24
}
25
void
26
set (
float
new_value,
bool
now =
false
)
27
{
28
if
(now)
29
{
30
steps_ = 0;
31
value_ = new_value;
32
}
33
else
if
(new_value != value_)
34
{
35
if
(!steps_)
36
linear_value_ = value_;
37
38
linear_step_ = (new_value - linear_value_) / total_steps_;
39
steps_ = total_steps_;
40
value_ = new_value;
41
}
42
}
43
float
44
get_next()
45
{
46
if
(!steps_)
47
return
value_;
48
else
49
{
50
steps_--;
51
linear_value_ += linear_step_;
52
return
linear_value_;
53
}
54
}
55
bool
56
is_constant()
57
{
58
return
steps_ == 0;
59
}
60
};
61
62
}
63
std::atomic
Ase::LinearSmooth
Definition
linearsmooth.hh:13
Ase
The Anklang C++ API namespace.
Definition
api.hh:8
Ase::uint
uint32_t uint
Provide 'uint' as convenience type.
Definition
cxxaux.hh:17
string
time
time
« « « Anklang Documentation