Jamoma API  0.6.0.a19
TTNoise.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspGeneratorLib
4  *
5  * @brief GeneratorLib: Noise Generator
6  *
7  * @details
8  *
9  * @authors Tim Place, Nils Peters, Trond Lossius
10  *
11  * @copyright Copyright © 2003 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #ifndef __TT_NOISE_H__
18 #define __TT_NOISE_H__
19 
20 #include "TTDSP.h"
21 
22 // Use the following to use the mt algorithm, otherwise compile with built-in (but less capable) algorithm
23 #define USE_MERSENNE_TWISTER_ALGORITHM
24 
25 #ifdef USE_MERSENNE_TWISTER_ALGORITHM
26 #include "MersenneTwister.h"
27 #endif
28 
29 
30 /** Noise Generator.
31  */
34 
35 protected:
36 
37 #ifdef USE_MERSENNE_TWISTER_ALGORITHM
38  MTRand mTwister; ///< Class implementing Mersenne Twister algorithm
39  TTFloat64 mMean; ///< Mean value for gauss distribution process method
40  TTFloat64 mStd; ///< Standard deviation value for gauss distribution process method
41 #endif
42 
43  TTSymbol mMode; ///< Attribute: what color is the noise?
44  TTFloat64 mGain; ///< Gain stage
45  TTChannelCount mNumChannels; ///< Sets the number of noise channels
46  TTUInt32 accum; ///< Accumulator for the noise generation
47  TTSampleVector mb0; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
48  TTSampleVector mb1; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
49  TTSampleVector mb2; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
50  TTSampleVector mb3; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
51  TTSampleVector mb4; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
52  TTSampleVector mb5; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
53  TTSampleVector mb6; ///< Internal coefficient used to keep track of past values. Used for some noise algorithms.
54 
55 
56  /** Audio processing method generating white noise.
57  @param inputs The input signal to process.
58  @param outputs The processed audio signal.
59  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
60  */
62 
63 
64 #ifdef USE_MERSENNE_TWISTER_ALGORITHM
65  /** Audio processing method using the mersenne twister algorithm for gaussian distribution noise.
66  @param inputs The input signal to process.
67  @param outputs The processed audio signal.
68  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
69  */
71 #endif
72 
73 
74  /** Audio processing method generating pink noise.
75  @param inputs The input signal to process.
76  @param outputs The processed audio signal.
77  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
78  */
80 
81 
82  /** Audio processing method generating brown noise.
83  @param inputs The input signal to process.
84  @param outputs The processed audio signal.
85  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
86  */
88 
89 
90  /** Audio processing method generating blue noise.
91  @param inputs The input signal to process.
92  @param outputs The processed audio signal.
93  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
94  */
96 
97 
98  ///// Attribute setters /////
99 
100  /** Set the mode, that is: Set what kind of noise to generate.
101  @param newMode The noise mode that we want to use.
102  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
103  */
104  TTErr setMode(const TTValue& newMode);
105 
106 
107  /** Set the overall gain of the generated noise signal.
108  @@param newValue The new value that we want to apply for gain scaling.
109  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
110  */
111  TTErr setGain(const TTValue& newValue);
112 
113 
114  /** Set the number of channels to process.
115  @param newNumChannels The number of channels to process.
116  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
117  */
118  TTErr setNumChannels(const TTChannelCount newNumChannels);
119 
120 
121  /** Get the current value used for scaling overall gain level of the generated noise signal.
122  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
123  */
124  TTErr getGain(TTValue& returnedValue);
125 
126 
127  /** Clear past values used internally by various noise generator algorithms.
128  @return #TTErr error code if the method fails to execute, else #kTTErrNone.
129  */
130  TTErr Clear();
131 };
132 
133 
134 #endif // __TT_NOISE_H__
TTErr setGain(const TTValue &newValue)
Set the overall gain of the generated noise signal.
Definition: TTNoise.cpp:95
TTSymbol mMode
Attribute: what color is the noise?
Definition: TTNoise.h:43
TTSampleVector mb0
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:47
TTSampleVector mb5
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:52
TTErr processPinkNoise(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method generating pink noise.
Definition: TTNoise.cpp:138
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
TTFloat64 mStd
Standard deviation value for gauss distribution process method.
Definition: TTNoise.h:40
TTErr processGauss(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method using the mersenne twister algorithm for gaussian distribution noise...
TTErr setMode(const TTValue &newMode)
Set the mode, that is: Set what kind of noise to generate.
Definition: TTNoise.cpp:79
TTSampleVector mb6
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:53
TTChannelCount mNumChannels
Sets the number of noise channels.
Definition: TTNoise.h:45
Jamoma DSP Library.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
MTRand mTwister
Class implementing Mersenne Twister algorithm.
Definition: TTNoise.h:38
#define TTCLASS_SETUP(className)
TODO Doxygen: need more comments here.
Definition: TTFoundation.h:54
TTSampleVector mb4
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:51
TTErr processWhiteNoise(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method generating white noise.
Definition: TTNoise.cpp:109
TTErr Clear()
Clear past values used internally by various noise generator algorithms.
Definition: TTNoise.cpp:66
std::vector< TTSampleValue > TTSampleVector
A TTSampleVector is simply a pointer to the first of an array of TTSampleValues.
Definition: TTBase.h:233
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTFloat64 mMean
Mean value for gauss distribution process method.
Definition: TTNoise.h:39
TTFloat64 mGain
Gain stage.
Definition: TTNoise.h:44
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
Definition: TTAudioSignal.h:31
TTErr processBlueNoise(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method generating blue noise.
Definition: TTNoise.cpp:217
A simple container for an array of TTAudioSignal pointers.
TTErr getGain(TTValue &returnedValue)
Get the current value used for scaling overall gain level of the generated noise signal.
Definition: TTNoise.cpp:102
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTErr setNumChannels(const TTChannelCount newNumChannels)
Set the number of channels to process.
Definition: TTNoise.cpp:51
TTSampleVector mb3
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:50
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
TTSampleVector mb2
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:49
TTSampleVector mb1
Internal coefficient used to keep track of past values. Used for some noise algorithms.
Definition: TTNoise.h:48
TTErr processBrownNoise(TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
Audio processing method generating brown noise.
Definition: TTNoise.cpp:179
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
Noise Generator.
Definition: TTNoise.h:32
TTUInt32 accum
Accumulator for the noise generation.
Definition: TTNoise.h:46