Nebula
Loading...
Searching...
No Matches
envelopecurve.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
13#include "math/scalar.h"
14#include "core/types.h"
15
16//------------------------------------------------------------------------------
17namespace Particles
18{
20{
21public:
24 {
25 Sine = 0,
27 };
28
32 void Setup(float val0, float val1, float val2, float val3, float keyPos0, float keyPos1, float freq, float amp, ModFunc mod);
34 float Sample(float t) const;
36 void PreSample(float* sampleBuffer, SizeT numSamples, SizeT sampleStride) const;
38 float GetMaxValue() const;
40 float GetMinValue() const;
42 const float* GetValues() const;
44 void SetValues(float v0, float v1, float v2, float v3);
46 const float* GetLimits() const;
48 void SetLimits(float min, float max);
50 const float GetKeyPos0() const;
52 void SetKeyPos0(float f);
54 const float GetKeyPos1() const;
56 void SetKeyPos1(float f);
58 const float GetFrequency() const;
60 void SetFrequency(float f);
62 const float GetAmplitude() const;
64 void SetAmplitude(float f);
66 const int GetModFunc() const;
68 void SetModFunc(int func);
69
70private:
71 float values[4];
72 float limits[2];
73 float keyPos0;
74 float keyPos1;
75 float frequency;
76 float amplitude;
78};
79
80//------------------------------------------------------------------------------
83inline const float*
85{
86 return this->values;
87}
88
89//------------------------------------------------------------------------------
92inline void
93EnvelopeCurve::SetValues( float v0, float v1, float v2, float v3 )
94{
95 this->values[0] = v0;
96 this->values[1] = v1;
97 this->values[2] = v2;
98 this->values[3] = v3;
99}
100
101//------------------------------------------------------------------------------
104inline const float
106{
107 return this->keyPos0;
108}
109
110//------------------------------------------------------------------------------
113inline void
115{
116 this->keyPos0 = f;
117}
118
119//------------------------------------------------------------------------------
122inline const float
124{
125 return this->keyPos1;
126}
127
128//------------------------------------------------------------------------------
131inline void
133{
134 this->keyPos1 = f;
135}
136
137//------------------------------------------------------------------------------
140inline const float
142{
143 return this->frequency;
144}
145
146//------------------------------------------------------------------------------
149inline void
151{
152 this->frequency = f;
153}
154
155//------------------------------------------------------------------------------
158inline const float
160{
161 return this->amplitude;
162}
163
164//------------------------------------------------------------------------------
167inline void
169{
170 this->amplitude = f;
171}
172
173//------------------------------------------------------------------------------
176inline const int
178{
179 return this->modFunction;
180}
181
182//------------------------------------------------------------------------------
185inline void
187{
188 this->modFunction = (ModFunc)i;
189}
190
191
192//------------------------------------------------------------------------------
195inline const float*
197{
198 return this->limits;
199}
200
201//------------------------------------------------------------------------------
204inline void
206{
207 this->limits[0] = min;
208 this->limits[1] = max;
209}
210
211} // namespace Particles
212//------------------------------------------------------------------------------
An Attack/Sustain/Release envelope curve class with optional sine/cosine modulation.
Definition envelopecurve.h:20
float limits[2]
Definition envelopecurve.h:72
EnvelopeCurve()
default constructor
Definition envelopecurve.cc:15
const float * GetValues() const
get values
Definition envelopecurve.h:84
float keyPos1
Definition envelopecurve.h:74
void Setup(float val0, float val1, float val2, float val3, float keyPos0, float keyPos1, float freq, float amp, ModFunc mod)
set parameters
Definition envelopecurve.cc:35
void SetKeyPos0(float f)
set keypos0
Definition envelopecurve.h:114
const float GetFrequency() const
get frequency
Definition envelopecurve.h:141
void SetModFunc(int func)
set mod function
Definition envelopecurve.h:186
const float GetKeyPos0() const
get keypos0
Definition envelopecurve.h:105
const float GetKeyPos1() const
get keypos1
Definition envelopecurve.h:123
const float GetAmplitude() const
get amplitude
Definition envelopecurve.h:159
float keyPos0
Definition envelopecurve.h:73
ModFunc
modulation enumerator
Definition envelopecurve.h:24
@ Cosine
Definition envelopecurve.h:26
@ Sine
Definition envelopecurve.h:25
float amplitude
Definition envelopecurve.h:76
void SetFrequency(float f)
set frequency
Definition envelopecurve.h:150
const float * GetLimits() const
get limits in y
Definition envelopecurve.h:196
void PreSample(float *sampleBuffer, SizeT numSamples, SizeT sampleStride) const
sample from t=0 to t=1 into array of values
Definition envelopecurve.cc:91
float GetMaxValue() const
get the max of val0, val1, val2, val3
Definition envelopecurve.cc:109
const int GetModFunc() const
get modFunction
Definition envelopecurve.h:177
float GetMinValue() const
get the min of val0, v1l, val2, val3
Definition envelopecurve.cc:118
void SetLimits(float min, float max)
set limits in y
Definition envelopecurve.h:205
float frequency
Definition envelopecurve.h:75
float Sample(float t) const
sample at specific time (0..1)
Definition envelopecurve.cc:54
float values[4]
Definition envelopecurve.h:71
void SetKeyPos1(float f)
set keypos1
Definition envelopecurve.h:132
void SetAmplitude(float f)
set amplitude
Definition envelopecurve.h:168
void SetValues(float v0, float v1, float v2, float v3)
set values
Definition envelopecurve.h:93
ModFunc modFunction
Definition envelopecurve.h:77
__forceinline TYPE min(TYPE a, TYPE b)
Definition scalar.h:390
__forceinline TYPE max(TYPE a, TYPE b)
Definition scalar.h:359
Particle context controls playing and enabling/disabling of particle emitters inside a model.
Definition modelnode.h:37
Nebula's scalar datatype.
int SizeT
Definition types.h:49