LMMS
Loading...
Searching...
No Matches
plugins
Delay
Lfo.h
Go to the documentation of this file.
1
/*
2
* lfo.h - declaration of Lfo class, a simple sine lfo
3
*
4
* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
5
*
6
* This file is part of LMMS - https://lmms.io
7
*
8
* This program is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU General Public
10
* License as published by the Free Software Foundation; either
11
* version 2 of the License, or (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public
19
* License along with this program (see COPYING); if not, write to the
20
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
* Boston, MA 02110-1301 USA.
22
*
23
*/
24
25
#ifndef LFO_H
26
#define LFO_H
27
28
#include <cmath>
29
#include <numbers>
30
31
namespace
lmms
32
{
33
34
35
class
Lfo
36
{
37
public
:
38
Lfo
(
int
samplerate );
39
~Lfo
() =
default
;
40
41
42
43
44
inline
void
setFrequency
(
double
frequency )
45
{
46
if
( frequency < 0 || frequency > (
m_samplerate
/ 2.0 ) || frequency ==
m_frequency
)
47
{
48
return
;
49
}
50
m_frequency
= frequency;
51
m_increment
=
m_frequency
*
m_twoPiOverSr
;
52
53
m_phase
= std::fmod(
m_phase
, 2 * std::numbers::pi_v<float>);
54
}
55
56
57
58
59
inline
void
setSampleRate
(
int
samplerate )
60
{
61
m_samplerate
= samplerate;
62
m_twoPiOverSr
= 2 * std::numbers::pi_v<float> / samplerate;
63
m_increment
=
m_frequency
*
m_twoPiOverSr
;
64
}
65
66
67
68
69
float
tick
();
70
71
private
:
72
double
m_frequency
;
73
double
m_phase
;
74
double
m_increment
;
75
double
m_twoPiOverSr
;
76
int
m_samplerate
;
77
};
78
79
80
}
// namespace lmms
81
82
#endif
// LFO_H
lmms::Lfo::Lfo
Lfo(int samplerate)
Definition
Lfo.cpp:34
lmms::Lfo::~Lfo
~Lfo()=default
lmms::Lfo::m_frequency
double m_frequency
Definition
Lfo.h:72
lmms::Lfo::m_samplerate
int m_samplerate
Definition
Lfo.h:76
lmms::Lfo::m_twoPiOverSr
double m_twoPiOverSr
Definition
Lfo.h:75
lmms::Lfo::m_phase
double m_phase
Definition
Lfo.h:73
lmms::Lfo::setSampleRate
void setSampleRate(int samplerate)
Definition
Lfo.h:59
lmms::Lfo::setFrequency
void setFrequency(double frequency)
Definition
Lfo.h:44
lmms::Lfo::m_increment
double m_increment
Definition
Lfo.h:74
lmms::Lfo::tick
float tick()
Definition
Lfo.cpp:43
lmms
Definition
AudioAlsa.cpp:35
Generated on
for LMMS by
1.16.1