| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2017 F4EXB                                                      //
 | 
					
						
							|  |  |  | // written by Edouard Griffiths                                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:32:15 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-29 00:55:04 +02:00
										 |  |  | #ifndef SDRBASE_DSP_PROJECTOR_H
 | 
					
						
							|  |  |  | #define SDRBASE_DSP_PROJECTOR_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 18:36:27 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | #include "dsptypes.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-12 18:36:27 +01:00
										 |  |  | class SDRBASE_API Projector | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     enum ProjectionType | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ProjectionReal = 0, //!< Extract real part
 | 
					
						
							|  |  |  |         ProjectionImag,     //!< Extract imaginary part
 | 
					
						
							|  |  |  |         ProjectionMagLin,   //!< Calculate linear magnitude or modulus
 | 
					
						
							| 
									
										
										
										
											2018-06-26 00:43:19 +02:00
										 |  |  |         ProjectionMagSq,    //!< Calculate linear squared magnitude or power
 | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  |         ProjectionMagDB,    //!< Calculate logarithmic (dB) of squared magnitude
 | 
					
						
							|  |  |  |         ProjectionPhase,    //!< Calculate phase
 | 
					
						
							| 
									
										
										
										
											2019-11-15 22:58:18 +01:00
										 |  |  |         ProjectionDOAP,     //!< Calculate ambiguous DOA from phase as phase difference (assuming positive)
 | 
					
						
							|  |  |  |         ProjectionDOAN,     //!< Calculate ambiguous DOA from phase as phase difference (assuming negative)
 | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  |         ProjectionDPhase,   //!< Calculate phase derivative i.e. instantaneous frequency scaled to sample rate
 | 
					
						
							| 
									
										
										
										
											2018-05-22 13:54:01 +02:00
										 |  |  |         ProjectionBPSK,     //!< Phase comparator BPSK evaluation
 | 
					
						
							|  |  |  |         ProjectionQPSK,     //!< Phase comparator QPSK evaluation
 | 
					
						
							|  |  |  |         Projection8PSK,     //!< Phase comparator 8-PSK evaluation
 | 
					
						
							|  |  |  |         Projection16PSK,    //!< Phase comparator 16-PSK evaluation
 | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | 		nbProjectionTypes   //!< Gives the number of projections in the enum
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Projector(ProjectionType projectionType); | 
					
						
							|  |  |  |     ~Projector(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     ProjectionType getProjectionType() const { return m_projectionType; } | 
					
						
							|  |  |  |     void settProjectionType(ProjectionType projectionType) { m_projectionType = projectionType; } | 
					
						
							|  |  |  |     void setCache(Real *cache) { m_cache = cache; } | 
					
						
							|  |  |  |     void setCacheMaster(bool cacheMaster) { m_cacheMaster = cacheMaster; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Real run(const Sample& s); | 
					
						
							| 
									
										
										
										
											2021-06-23 15:53:28 +02:00
										 |  |  |     Real run(const std::complex<float>& s); | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2018-05-22 13:54:01 +02:00
										 |  |  |     static Real normalizeAngle(Real angle); | 
					
						
							| 
									
										
										
										
											2018-04-03 18:51:21 +02:00
										 |  |  |     ProjectionType m_projectionType; | 
					
						
							|  |  |  |     Real m_prevArg; | 
					
						
							|  |  |  |     Real *m_cache; | 
					
						
							|  |  |  |     bool m_cacheMaster; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-05-29 00:55:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // SDRBASE_DSP_PROJECTOR_H
 |