16 template <
typename RealType>
103 {this->clipMin =
clipMin;
return *
this;}
118 {this->clipMax =
clipMax;
return *
this;}
142 inline RealType
clip(RealType v);
152 {
return this->fixedLifespan != 1L;}
220 template<
typename _RealType>
235 template <
typename RealType>
238 if(v > getClipMax())
return getClipMax();
239 if(v < getClipMin())
return getClipMin();
247 template <
typename RealType>
249 fixedValue = noiseFunction();
250 fixedRemainingUses = fixedLifespan;
257 template <
typename RealType>
260 if(fixedLifespan != 1L){
261 if(fixedLifespan == 0L)
return fixedValue;
262 if(fixedRemainingUses > 0L){
263 fixedRemainingUses--;
269 fixedValue = clip(noiseFunction());
272 if(fixedLifespan > 1L){
273 fixedRemainingUses = fixedLifespan-1;
282 template<
typename RealType>
284 std::stringstream ss;
285 ss <<
"Noise source ("<<&ns<<
"):\n"
286 <<
"\tclipMin = " << ns.
clipMin <<
"\n"
287 <<
"\tclipMax = " << ns.
clipMax <<
"\n"
291 <<
"\tfixedValue = " << ns.
fixedValue <<
"\n";
Class to handle a noise source.
Definition: NoiseSource.h:17
RealType next()
Obtain the next default noise value.
Definition: NoiseSource.h:258
NoiseSource & setFixedLifespan(unsigned long fixedLifespan)
Set the fixed value lifespan.
Definition: NoiseSource.h:168
NoiseSource & setFixedValueRemainingUses(unsigned long remainingUses)
Update remaining uses count for current fixed value.
Definition: NoiseSource.h:186
unsigned long getFixedLifespan()
Obtain the fixed value lifespan.
Definition: NoiseSource.h:158
bool isFixedValueEnabled()
Check if fixed value usage is enabled or not.
Definition: NoiseSource.h:151
NoiseSource & fixedRenew()
Forces a renewal of fixed value and its remaining uses.
Definition: NoiseSource.h:248
RealType clip(RealType v)
If clipping is enabled, it will clip received value. If clipping is not enabled, received value will ...
Definition: NoiseSource.h:236
unsigned long getFixedValueRemainingUses()
Obtain the remaining uses of current fixed value.
Definition: NoiseSource.h:179
virtual RealType noiseFunction()=0
Function which computes noise values.
double getClipMax()
Obtain the clip max value.
Definition: NoiseSource.h:109
NoiseSource & setClipMax(RealType clipMax)
Set the clip max value.
Definition: NoiseSource.h:117
NoiseSource & setClipEnabled(bool clipEnabled)
Enable clipping by setting it to true or disable it by setting to false.
Definition: NoiseSource.h:132
RealType clipMin
All noise values which are less than clipMin will be clipped to clipMin if clipping is enabled.
Definition: NoiseSource.h:28
unsigned long fixedLifespan
Specify the how many times a fixed value can be used before being renewed.
Definition: NoiseSource.h:65
unsigned long fixedRemainingUses
How many remaining uses the fixed value has.
Definition: NoiseSource.h:71
RealType fixedValue
The fixed value.
Definition: NoiseSource.h:77
bool clipEnabled
True when clipping is enabled, False otherwise.
Definition: NoiseSource.h:37
double getClipMin()
Obtain the clip min value.
Definition: NoiseSource.h:94
friend std::ostream & operator<<(std::ostream &out, NoiseSource< _RealType > const &ns)
Output stream behavior.
bool isClipEnabled()
Check if clipping is enabled or not.
Definition: NoiseSource.h:124
RealType clipMax
All noise values which are greater than clipMax will be clipped to clipMaxx if clipping is enabled.
Definition: NoiseSource.h:33
void build()
Common behavior for all NoiseSource constructors.
Definition: NoiseSource.h:85
NoiseSource & setClipMin(RealType clipMin)
Set the clip min value.
Definition: NoiseSource.h:102