1+ #pragma  once
2+ 
3+ #include  " TSignalLine.h" 
4+ 
5+ #include  < cstdint> 
6+ #include  < memory> 
7+ #include  < string> 
8+ 
9+ /* *
10+  * @namespace NGEN 
11+  * @brief Contains default parameters used in noise generation. 
12+  */  
13+ namespace  NGEN  {
14+ 
15+ static  constexpr  double  DEFAULT_NOISE_AMPLITUDE = 1.0 ;  // /< Default noise
16+                                                         // /< amplitude.
17+ static  const  std::string DEFAULT_GRAPH_LABEL =
18+     " Noisy Signal" // /< Default graph label.
19+ 
20+ }  //  namespace NGEN
21+ 
22+ //  TODO: Add noise types:
23+ //  - `Gaussian`: Generates Gaussian (normal) noise with a specified mean and
24+ //  standard deviation.
25+ //  - `Pink`: Generates pink noise, which has equal energy per octave (or \(1/f\)
26+ //  noise).
27+ //  - `Brown`: Generates brown noise (also called red noise), which decreases
28+ //  power as \(1/f^2\).
29+ //  - `Blue`: Generates blue noise, which increases power as \(f\).
30+ //  - `Violet`: Generates violet noise, where power increases as \(f^2\).
31+ //  - `Impulse`: Generates impulse noise with random spikes.
32+ /* *
33+  * @enum NoiseType 
34+  * @brief Specifies the types of noise that can be applied to a signal. 
35+  * 
36+  * This enumeration defines various types of noise that can be used in signal 
37+  * processing: 
38+  * 
39+  * - `White`: Generates white noise with uniform random values. 
40+  */  
41+ enum  class  NoiseType  : std::uint8_t  {
42+   White  // /< White noise (uniform distribution).
43+ };
44+ 
45+ /* *
46+  * @struct TNoiseGeneratorParams 
47+  * @brief Parameters for generating a noisy signal line. 
48+  */  
49+ struct  TNoiseGeneratorParams  {
50+   const  TSignalLine* signalLine =
51+       nullptr ;  // /< Pointer to the signal line to add noise to.
52+   double  noiseAmplitude =
53+       NGEN::DEFAULT_NOISE_AMPLITUDE;  // /< (optional) Amplitude of the noise.
54+   NoiseType noiseType =
55+       NoiseType::White;  // /< (optional) Type of noise to apply.
56+   std::string graphLabel =
57+       NGEN::DEFAULT_GRAPH_LABEL;  // /< (optional) Label for the graph.
58+ };
59+ 
60+ /* *
61+  * @class TNoiseGenerator 
62+  * @brief Class for generating a noisy signal line. 
63+  * 
64+  * The TNoiseGenerator class is responsible for adding noise to an existing 
65+  * signal line. It provides methods to retrieve the noisy signal and its 
66+  * parameters. 
67+  */  
68+ class  TNoiseGenerator  {
69+  public: 
70+   /* *
71+    * @brief Constructs a TNoiseGenerator with a signal line and noise 
72+    * parameters. 
73+    * 
74+    * @param signalLine Pointer to the signal line to add noise to. 
75+    * @param noiseType (optional) The type of noise to apply. 
76+    * @param graphLabel (optional) Label for the graph. 
77+    */  
78+   TNoiseGenerator (const  TSignalLine* signalLine,
79+                   double  noiseAmplitude = NGEN::DEFAULT_NOISE_AMPLITUDE,
80+                   NoiseType noiseType = NoiseType::White,
81+                   std::string graphLabel = NGEN::DEFAULT_GRAPH_LABEL);
82+ 
83+   /* *
84+    * @brief Constructs a TNoiseGenerator with noise generation parameters. 
85+    * 
86+    * @param params Structure containing the parameters for noise generation. 
87+    */  
88+   TNoiseGenerator (TNoiseGeneratorParams params);
89+ 
90+   /* *
91+    * @brief Default destructor. 
92+    */  
93+   ~TNoiseGenerator () = default ;
94+ 
95+   /* *
96+    * @brief Default copy constructor. 
97+    */  
98+   TNoiseGenerator (const  TNoiseGenerator&) = default ;
99+ 
100+   /* *
101+    * @brief Default move constructor. 
102+    */  
103+   TNoiseGenerator (TNoiseGenerator&&) noexcept  = default ;
104+ 
105+   /* *
106+    * @brief Default copy assignment operator. 
107+    */  
108+   TNoiseGenerator& operator =(const  TNoiseGenerator&) = default ;
109+ 
110+   /* *
111+    * @brief Default move assignment operator. 
112+    */  
113+   TNoiseGenerator& operator =(TNoiseGenerator&&) noexcept  = default ;
114+ 
115+   /* *
116+    * @brief Retrieves the noisy signal line. 
117+    * 
118+    * @return const TSignalLine* Pointer to the resulting noisy signal line. 
119+    */  
120+   [[nodiscard]] const  TSignalLine* getSignalLine () const ;
121+ 
122+   /* *
123+    * @brief Retrieves the parameters used for noise generation. 
124+    * 
125+    * @return const TNoiseGeneratorParams& Reference to the noise generation 
126+    * parameters. 
127+    */  
128+   [[nodiscard]] const  TNoiseGeneratorParams& getParams () const ;
129+ 
130+   /* *
131+    * @brief Executes the noise generation process. 
132+    */  
133+   void  execute ();
134+ 
135+  private: 
136+   std::unique_ptr<TSignalLine> _sl =
137+       nullptr ;                         // /< Pointer to the noisy signal line.
138+   TNoiseGeneratorParams _params = {};  // /< Parameters for noise generation.
139+ };
0 commit comments