LMMS
Loading...
Searching...
No Matches
EnvelopeAndLfoParameters.h
Go to the documentation of this file.
1/*
2 * EnvelopeAndLfoParameters.h - class EnvelopeAndLfoParameters
3 *
4 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
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 LMMS_ENVELOPE_AND_LFO_PARAMETERS_H
26#define LMMS_ENVELOPE_AND_LFO_PARAMETERS_H
27
28#include <memory>
29
30#include "JournallingObject.h"
31#include "AutomatableModel.h"
32#include "SampleBuffer.h"
33#include "TempoSyncKnobModel.h"
34#include "LmmsTypes.h"
35
36namespace lmms
37{
38
39namespace gui
40{
41
43
44}
45
46class LMMS_EXPORT EnvelopeAndLfoParameters : public Model, public JournallingObject
47{
48 Q_OBJECT
49public:
51 {
52 public:
53 LfoInstances() = default;
54
55 ~LfoInstances() = default;
56
57 inline bool isEmpty() const
58 {
59 return m_lfos.isEmpty();
60 }
61
62 void trigger();
63 void reset();
64
65 void add( EnvelopeAndLfoParameters * lfo );
66 void remove( EnvelopeAndLfoParameters * lfo );
67
68 private:
70 using LfoList = QList<EnvelopeAndLfoParameters*>;
72
73 };
74
75 enum class LfoShape
76 {
77 SineWave,
78 TriangleWave,
79 SawWave,
80 SquareWave,
81 UserDefinedWave,
82 RandomWave,
84 };
85
86 EnvelopeAndLfoParameters( float _value_for_zero_amount,
87 Model * _parent );
89
90 static inline float expKnobVal( float _val )
91 {
92 return ( ( _val < 0 ) ? -_val : _val ) * _val;
93 }
94
96 {
97 return s_lfoInstances;
98 }
99
100 void fillLevel( float * _buf, f_cnt_t _frame,
101 const f_cnt_t _release_begin,
102 const f_cnt_t _frames );
103
104 inline bool isUsed() const
105 {
106 return m_used;
107 }
108
109
110 void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
111 void loadSettings( const QDomElement & _this ) override;
112 QString nodeName() const override
113 {
114 return "el";
115 }
116
117 inline f_cnt_t PAHD_Frames() const
118 {
119 return m_pahdFrames;
120 }
121
122 inline f_cnt_t releaseFrames() const
123 {
124 return m_rFrames;
125 }
126
127 // Envelope
128 const FloatModel& getPredelayModel() const { return m_predelayModel; }
129 const FloatModel& getAttackModel() const { return m_attackModel; }
130 const FloatModel& getHoldModel() const { return m_holdModel; }
131 const FloatModel& getDecayModel() const { return m_decayModel; }
132 const FloatModel& getSustainModel() const { return m_sustainModel; }
133 const FloatModel& getReleaseModel() const { return m_releaseModel; }
134 const FloatModel& getAmountModel() const { return m_amountModel; }
136
137
138 // LFO
142
146 const BoolModel& getX100Model() const { return m_x100Model; }
147 const IntModel& getLfoWaveModel() const { return m_lfoWaveModel; }
148 std::shared_ptr<const SampleBuffer> getLfoUserWave() const { return m_userWave; }
149
150public slots:
151 void updateSampleVars();
152
153
154protected:
155 void fillLfoLevel( float * _buf, f_cnt_t _frame, const f_cnt_t _frames );
156
157
158private:
160 bool m_used;
161
163
171
173 float m_amount;
182
183
189
192
193
203 std::shared_ptr<const SampleBuffer> m_userWave = SampleBuffer::emptyBuffer();
204
205 constexpr static auto NumLfoShapes = static_cast<std::size_t>(LfoShape::Count);
206
207 sample_t lfoShapeSample( f_cnt_t _frame_offset );
208 void updateLfoShapeData();
209
210
212
213} ;
214
215} // namespace lmms
216
217#endif // LMMS_ENVELOPE_AND_LFO_PARAMETERS_H
Definition AutomatableModel.h:497
Definition EnvelopeAndLfoParameters.h:51
QMutex m_lfoListMutex
Definition EnvelopeAndLfoParameters.h:69
bool isEmpty() const
Definition EnvelopeAndLfoParameters.h:57
QList< EnvelopeAndLfoParameters * > LfoList
Definition EnvelopeAndLfoParameters.h:70
LfoList m_lfos
Definition EnvelopeAndLfoParameters.h:71
Definition EnvelopeAndLfoParameters.h:47
const FloatModel & getPredelayModel() const
Definition EnvelopeAndLfoParameters.h:128
QMutex m_paramMutex
Definition EnvelopeAndLfoParameters.h:162
bool m_used
Definition EnvelopeAndLfoParameters.h:160
f_cnt_t getLfoPredelayFrames() const
Definition EnvelopeAndLfoParameters.h:139
static LfoInstances * s_lfoInstances
Definition EnvelopeAndLfoParameters.h:159
const TempoSyncKnobModel & getLfoSpeedModel() const
Definition EnvelopeAndLfoParameters.h:145
f_cnt_t m_pahdBufSize
Definition EnvelopeAndLfoParameters.h:180
std::shared_ptr< const SampleBuffer > getLfoUserWave() const
Definition EnvelopeAndLfoParameters.h:148
const FloatModel & getSustainModel() const
Definition EnvelopeAndLfoParameters.h:132
const FloatModel & getAmountModel() const
Definition EnvelopeAndLfoParameters.h:134
FloatModel m_predelayModel
Definition EnvelopeAndLfoParameters.h:164
const BoolModel & getX100Model() const
Definition EnvelopeAndLfoParameters.h:146
const FloatModel & getDecayModel() const
Definition EnvelopeAndLfoParameters.h:131
FloatModel m_decayModel
Definition EnvelopeAndLfoParameters.h:167
FloatModel m_amountModel
Definition EnvelopeAndLfoParameters.h:170
sample_t * m_pahdEnv
Definition EnvelopeAndLfoParameters.h:178
float m_amountAdd
Definition EnvelopeAndLfoParameters.h:175
float m_amount
Definition EnvelopeAndLfoParameters.h:173
bool m_lfoAmountIsZero
Definition EnvelopeAndLfoParameters.h:199
void updateLfoShapeData()
Definition EnvelopeAndLfoParameters.cpp:247
sample_t * m_rEnv
Definition EnvelopeAndLfoParameters.h:179
sample_t * m_lfoShapeData
Definition EnvelopeAndLfoParameters.h:200
FloatModel m_attackModel
Definition EnvelopeAndLfoParameters.h:165
f_cnt_t PAHD_Frames() const
Definition EnvelopeAndLfoParameters.h:117
const FloatModel & getLfoAmountModel() const
Definition EnvelopeAndLfoParameters.h:143
const IntModel & getLfoWaveModel() const
Definition EnvelopeAndLfoParameters.h:147
f_cnt_t m_pahdFrames
Definition EnvelopeAndLfoParameters.h:176
f_cnt_t getLfoOscillationFrames() const
Definition EnvelopeAndLfoParameters.h:141
sample_t m_random
Definition EnvelopeAndLfoParameters.h:201
BoolModel m_x100Model
Definition EnvelopeAndLfoParameters.h:190
const FloatModel & getHoldModel() const
Definition EnvelopeAndLfoParameters.h:130
f_cnt_t m_lfoAttackFrames
Definition EnvelopeAndLfoParameters.h:195
QString nodeName() const override
Definition EnvelopeAndLfoParameters.h:112
f_cnt_t m_rFrames
Definition EnvelopeAndLfoParameters.h:177
sample_t lfoShapeSample(f_cnt_t _frame_offset)
Definition EnvelopeAndLfoParameters.cpp:209
static float expKnobVal(float _val)
Definition EnvelopeAndLfoParameters.h:90
FloatModel m_sustainModel
Definition EnvelopeAndLfoParameters.h:168
bool m_bad_lfoShapeData
Definition EnvelopeAndLfoParameters.h:202
f_cnt_t m_lfoPredelayFrames
Definition EnvelopeAndLfoParameters.h:194
FloatModel m_lfoAmountModel
Definition EnvelopeAndLfoParameters.h:187
FloatModel & getAmountModel()
Definition EnvelopeAndLfoParameters.h:135
float m_valueForZeroAmount
Definition EnvelopeAndLfoParameters.h:174
const FloatModel & getAttackModel() const
Definition EnvelopeAndLfoParameters.h:129
f_cnt_t getLfoAttackFrames() const
Definition EnvelopeAndLfoParameters.h:140
IntModel m_lfoWaveModel
Definition EnvelopeAndLfoParameters.h:188
f_cnt_t m_lfoOscillationFrames
Definition EnvelopeAndLfoParameters.h:196
float m_lfoAmount
Definition EnvelopeAndLfoParameters.h:198
std::shared_ptr< const SampleBuffer > m_userWave
Definition EnvelopeAndLfoParameters.h:203
BoolModel m_controlEnvAmountModel
Definition EnvelopeAndLfoParameters.h:191
FloatModel & getLfoAmountModel()
Definition EnvelopeAndLfoParameters.h:144
static LfoInstances * instances()
Definition EnvelopeAndLfoParameters.h:95
FloatModel m_lfoAttackModel
Definition EnvelopeAndLfoParameters.h:185
FloatModel m_holdModel
Definition EnvelopeAndLfoParameters.h:166
static constexpr auto NumLfoShapes
Definition EnvelopeAndLfoParameters.h:205
f_cnt_t m_lfoFrame
Definition EnvelopeAndLfoParameters.h:197
LfoShape
Definition EnvelopeAndLfoParameters.h:76
@ Count
Definition EnvelopeAndLfoParameters.h:83
FloatModel m_lfoPredelayModel
Definition EnvelopeAndLfoParameters.h:184
const FloatModel & getReleaseModel() const
Definition EnvelopeAndLfoParameters.h:133
FloatModel m_releaseModel
Definition EnvelopeAndLfoParameters.h:169
EnvelopeAndLfoParameters(float _value_for_zero_amount, Model *_parent)
Definition EnvelopeAndLfoParameters.cpp:94
f_cnt_t m_rBufSize
Definition EnvelopeAndLfoParameters.h:181
f_cnt_t releaseFrames() const
Definition EnvelopeAndLfoParameters.h:122
TempoSyncKnobModel m_lfoSpeedModel
Definition EnvelopeAndLfoParameters.h:186
bool isUsed() const
Definition EnvelopeAndLfoParameters.h:104
float m_sustainLevel
Definition EnvelopeAndLfoParameters.h:172
Definition AutomatableModel.h:463
Definition AutomatableModel.h:481
JournallingObject()
Definition JournallingObject.cpp:36
Definition Model.h:37
Model(Model *parent, QString displayName=QString(), bool defaultConstructed=false)
Definition Model.cpp:30
static auto emptyBuffer() -> std::shared_ptr< const SampleBuffer >
Definition SampleBuffer.cpp:67
Definition TempoSyncKnobModel.h:45
Definition EnvelopeAndLfoView.h:52
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
float sample_t
Definition LmmsTypes.h:39
@ Count
Definition Sfxr.h:43
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43