1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
|
/*
* EnvelopeAndLfoParameters.h - class EnvelopeAndLfoParameters
*
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef ENVELOPE_AND_LFO_PARAMETERS_H
#define ENVELOPE_AND_LFO_PARAMETERS_H
#include <QtCore/QVector>
#include "JournallingObject.h"
#include "AutomatableModel.h"
#include "SampleBuffer.h"
#include "TempoSyncKnobModel.h"
#include "lmms_basics.h"
class EXPORT EnvelopeAndLfoParameters : public Model, public JournallingObject
{
Q_OBJECT
public:
class LfoInstances
{
public:
LfoInstances()
{
}
~LfoInstances()
{
}
inline bool isEmpty() const
{
return m_lfos.isEmpty();
}
void trigger();
void reset();
void add( EnvelopeAndLfoParameters * lfo );
void remove( EnvelopeAndLfoParameters * lfo );
private:
QMutex m_lfoListMutex;
typedef QList<EnvelopeAndLfoParameters *> LfoList;
LfoList m_lfos;
} ;
EnvelopeAndLfoParameters( float _value_for_zero_amount,
Model * _parent );
virtual ~EnvelopeAndLfoParameters();
static inline float expKnobVal( float _val )
{
return ( ( _val < 0 ) ? -_val : _val ) * _val;
}
static LfoInstances * instances()
{
return s_lfoInstances;
}
void fillLevel( float * _buf, f_cnt_t _frame,
const f_cnt_t _release_begin,
const fpp_t _frames );
inline bool isUsed() const
{
return m_used;
}
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
virtual QString nodeName() const
{
return "el";
}
inline f_cnt_t PAHD_Frames() const
{
return m_pahdFrames;
}
inline f_cnt_t releaseFrames() const
{
return m_rFrames;
}
public slots:
void updateSampleVars();
protected:
void fillLfoLevel( float * _buf, f_cnt_t _frame, const fpp_t _frames );
private:
static LfoInstances * s_lfoInstances;
bool m_used;
QMutex m_paramMutex;
FloatModel m_predelayModel;
FloatModel m_attackModel;
FloatModel m_holdModel;
FloatModel m_decayModel;
FloatModel m_sustainModel;
FloatModel m_releaseModel;
FloatModel m_amountModel;
float m_sustainLevel;
float m_amount;
float m_valueForZeroAmount;
float m_amountAdd;
f_cnt_t m_pahdFrames;
f_cnt_t m_rFrames;
sample_t * m_pahdEnv;
sample_t * m_rEnv;
f_cnt_t m_pahdBufSize;
f_cnt_t m_rBufSize;
FloatModel m_lfoPredelayModel;
FloatModel m_lfoAttackModel;
TempoSyncKnobModel m_lfoSpeedModel;
FloatModel m_lfoAmountModel;
IntModel m_lfoWaveModel;
BoolModel m_x100Model;
BoolModel m_controlEnvAmountModel;
f_cnt_t m_lfoPredelayFrames;
f_cnt_t m_lfoAttackFrames;
f_cnt_t m_lfoOscillationFrames;
f_cnt_t m_lfoFrame;
float m_lfoAmount;
bool m_lfoAmountIsZero;
sample_t * m_lfoShapeData;
sample_t m_random;
bool m_bad_lfoShapeData;
SampleBuffer m_userWave;
enum LfoShapes
{
SineWave,
TriangleWave,
SawWave,
SquareWave,
UserDefinedWave,
RandomWave,
NumLfoShapes
} ;
sample_t lfoShapeSample( fpp_t _frame_offset );
void updateLfoShapeData();
friend class EnvelopeAndLfoView;
} ;
#endif
|