| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2019 Edouard Griffiths, F4EXB.                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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-04-20 10:32:21 +02:00
										 |  |  | #ifndef SDRBASE_DSP_SPECTRUMSETTNGS_H
 | 
					
						
							|  |  |  | #define SDRBASE_DSP_SPECTRUMSETTNGS_H
 | 
					
						
							| 
									
										
										
										
											2020-04-30 14:42:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | #include <QByteArray>
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  | #include <QString>
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "export.h"
 | 
					
						
							|  |  |  | #include "dsp/dsptypes.h"
 | 
					
						
							| 
									
										
										
										
											2020-04-30 14:42:57 +02:00
										 |  |  | #include "dsp/fftwindow.h"
 | 
					
						
							| 
									
										
										
										
											2021-08-07 19:45:48 +02:00
										 |  |  | #include "dsp/spectrummarkers.h"
 | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | #include "dsp/spectrumcalibrationpoint.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-07 18:50:26 +02:00
										 |  |  | #include "settings/serializable.h"
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  | class SDRBASE_API SpectrumSettings : public Serializable | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     enum AveragingMode | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         AvgModeNone, | 
					
						
							|  |  |  |         AvgModeMoving, | 
					
						
							|  |  |  |         AvgModeFixed, | 
					
						
							|  |  |  |         AvgModeMax | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-24 16:44:44 +01:00
										 |  |  |     // Bitmask for which selection of markers to display
 | 
					
						
							| 
									
										
										
										
											2021-08-04 19:28:52 +02:00
										 |  |  |     enum MarkersDisplay | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-06-24 16:44:44 +01:00
										 |  |  |         MarkersDisplayNone = 0, | 
					
						
							|  |  |  |         MarkersDisplaySpectrum = 0x1, | 
					
						
							|  |  |  |         MarkersDisplayAnnotations = 0x2, | 
					
						
							|  |  |  |         MarkersDisplayAll = 0x3 | 
					
						
							| 
									
										
										
										
											2021-08-04 19:28:52 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  | 	enum CalibrationInterpolationMode | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2022-02-05 11:56:08 +01:00
										 |  |  | 		CalibInterpLinear, //!< linear power
 | 
					
						
							|  |  |  | 		CalibInterpLog     //!< log power (dB linear)
 | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     enum SpectrogramStyle | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Points, | 
					
						
							|  |  |  |         Lines, | 
					
						
							|  |  |  |         Solid, | 
					
						
							|  |  |  |         Outline, | 
					
						
							|  |  |  |         Shaded | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     enum SpectrumStyle | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Line, | 
					
						
							|  |  |  |         Fill, | 
					
						
							|  |  |  |         Gradient | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     enum Measurement | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |         MeasurementNone, | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  |         MeasurementPeaks, | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |         MeasurementChannelPower, | 
					
						
							|  |  |  |         MeasurementAdjacentChannelPower, | 
					
						
							| 
									
										
										
										
											2022-10-03 16:02:24 +01:00
										 |  |  |         MeasurementOccupiedBandwidth, | 
					
						
							|  |  |  |         Measurement3dBBandwidth, | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  |         MeasurementSNR | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     enum MeasurementsPosition { | 
					
						
							|  |  |  |         PositionAbove, | 
					
						
							|  |  |  |         PositionBelow, | 
					
						
							|  |  |  |         PositionLeft, | 
					
						
							|  |  |  |         PositionRight | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-08 23:40:28 +01:00
										 |  |  | 	int m_fftSize; | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	int m_fftOverlap; | 
					
						
							| 
									
										
										
										
											2020-04-30 14:42:57 +02:00
										 |  |  | 	FFTWindow::Function m_fftWindow; | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	Real m_refLevel; | 
					
						
							|  |  |  | 	Real m_powerRange; | 
					
						
							| 
									
										
										
										
											2021-02-12 00:53:18 +01:00
										 |  |  | 	int m_fpsPeriodMs; //!< FPS capping period in ms FPS = 1000/m_fpsPeriodMs. If zero: no limit.
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	int m_decay; | 
					
						
							|  |  |  | 	int m_decayDivisor; | 
					
						
							|  |  |  | 	int m_histogramStroke; | 
					
						
							|  |  |  | 	int m_displayGridIntensity; | 
					
						
							|  |  |  | 	int m_displayTraceIntensity; | 
					
						
							|  |  |  | 	bool m_displayWaterfall; | 
					
						
							|  |  |  | 	bool m_invertedWaterfall; | 
					
						
							|  |  |  |     Real m_waterfallShare; | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     bool m_display3DSpectrogram; | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	bool m_displayMaxHold; | 
					
						
							|  |  |  | 	bool m_displayCurrent; | 
					
						
							|  |  |  | 	bool m_displayHistogram; | 
					
						
							|  |  |  | 	bool m_displayGrid; | 
					
						
							| 
									
										
										
										
											2022-10-16 04:48:07 +02:00
										 |  |  |     bool m_truncateFreqScale; | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	AveragingMode m_averagingMode; | 
					
						
							|  |  |  | 	int m_averagingIndex; | 
					
						
							| 
									
										
										
										
											2020-11-10 16:38:12 +01:00
										 |  |  | 	unsigned int m_averagingValue; | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 	bool m_linear; //!< linear else logarithmic scale
 | 
					
						
							| 
									
										
										
										
											2020-11-09 17:14:17 +01:00
										 |  |  |     bool m_ssb;    //!< SSB display with spectrum center at start of array or display - else spectrum center is on center
 | 
					
						
							|  |  |  |     bool m_usb;    //!< USB display with increasing frequencies towads the right - else decreasing frequencies
 | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  | 	bool m_wsSpectrum;           //!< Start or stop websocket spectrum server
 | 
					
						
							|  |  |  |     QString m_wsSpectrumAddress; //!< websocket spectrum server address
 | 
					
						
							|  |  |  |     uint16_t m_wsSpectrumPort;   //!< websocket spectrum server port
 | 
					
						
							| 
									
										
										
										
											2021-08-08 04:28:22 +02:00
										 |  |  | 	QList<SpectrumHistogramMarker> m_histogramMarkers; | 
					
						
							|  |  |  | 	QList<SpectrumWaterfallMarker> m_waterfallMarkers; | 
					
						
							| 
									
										
										
										
											2022-01-21 00:18:41 +01:00
										 |  |  | 	QList<SpectrumAnnotationMarker> m_annoationMarkers; | 
					
						
							| 
									
										
										
										
											2022-10-03 00:23:47 +02:00
										 |  |  |     bool m_findHistogramPeaks; | 
					
						
							| 
									
										
										
										
											2022-01-22 06:57:46 +01:00
										 |  |  | 	MarkersDisplay m_markersDisplay; | 
					
						
							| 
									
										
										
										
											2022-01-30 07:43:50 +01:00
										 |  |  | 	QList<SpectrumCalibrationPoint> m_calibrationPoints; | 
					
						
							| 
									
										
										
										
											2022-02-04 08:38:04 +01:00
										 |  |  | 	bool m_useCalibration; | 
					
						
							|  |  |  | 	CalibrationInterpolationMode m_calibrationInterpMode; //!< How is power interpolated between calibration points
 | 
					
						
							| 
									
										
										
										
											2022-06-18 12:35:44 +01:00
										 |  |  |     SpectrogramStyle m_3DSpectrogramStyle; | 
					
						
							| 
									
										
										
										
											2022-06-22 08:52:48 +01:00
										 |  |  |     QString m_colorMap; | 
					
						
							|  |  |  |     SpectrumStyle m_spectrumStyle; | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     Measurement m_measurement; | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     int m_measurementCenterFrequencyOffset; | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     int m_measurementBandwidth; | 
					
						
							|  |  |  |     int m_measurementChSpacing; | 
					
						
							|  |  |  |     int m_measurementAdjChBandwidth; | 
					
						
							|  |  |  |     int m_measurementHarmonics; | 
					
						
							| 
									
										
										
										
											2022-09-28 16:59:35 +01:00
										 |  |  |     int m_measurementPeaks; | 
					
						
							| 
									
										
										
										
											2022-09-25 10:50:56 +01:00
										 |  |  |     bool m_measurementHighlight; | 
					
						
							| 
									
										
										
										
											2022-09-29 11:59:58 +01:00
										 |  |  |     MeasurementsPosition m_measurementsPosition; | 
					
						
							|  |  |  |     int m_measurementPrecision; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 11:54:58 +02:00
										 |  |  | 	static const int m_log2FFTSizeMin = 6;   // 64
 | 
					
						
							| 
									
										
										
										
											2021-04-21 07:20:56 +02:00
										 |  |  | 	static const int m_log2FFTSizeMax = 15;  // 32k
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  |     SpectrumSettings(); | 
					
						
							|  |  |  | 	virtual ~SpectrumSettings(); | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  |     void resetToDefaults(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-07 18:50:26 +02:00
										 |  |  |     virtual QByteArray serialize() const; | 
					
						
							|  |  |  |     virtual bool deserialize(const QByteArray& data); | 
					
						
							| 
									
										
										
										
											2021-12-01 00:20:14 +01:00
										 |  |  |     virtual void formatTo(SWGSDRangel::SWGObject *swgObject) const; | 
					
						
							|  |  |  |     virtual void updateFrom(const QStringList& keys, const SWGSDRangel::SWGObject *swgObject); | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-08 04:28:22 +02:00
										 |  |  | 	QList<SpectrumHistogramMarker>& getHistogramMarkers() { return m_histogramMarkers; } | 
					
						
							|  |  |  | 	QList<SpectrumWaterfallMarker>& getWaterfallMarkers() { return m_waterfallMarkers; } | 
					
						
							| 
									
										
										
										
											2022-10-03 00:23:47 +02:00
										 |  |  |     bool getHistogramFindPeaks() { return m_findHistogramPeaks; } | 
					
						
							| 
									
										
										
										
											2021-08-08 04:28:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  |     static int getAveragingMaxScale(AveragingMode averagingMode); //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000
 | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  |     static int getAveragingValue(int averagingIndex, AveragingMode averagingMode); | 
					
						
							|  |  |  |     static int getAveragingIndex(int averagingValue, AveragingMode averagingMode); | 
					
						
							| 
									
										
										
										
											2021-04-20 23:08:56 +02:00
										 |  |  | 	static uint64_t getMaxAveragingValue(int fftSize, AveragingMode averagingMode); | 
					
						
							| 
									
										
										
										
											2022-01-15 19:19:47 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	static int qColorToInt(const QColor& color); | 
					
						
							|  |  |  | 	static QColor intToQColor(int intColor); | 
					
						
							| 
									
										
										
										
											2019-08-05 01:56:29 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-04-30 14:42:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-20 10:32:21 +02:00
										 |  |  | #endif // SDRBASE_DSP_SPECTRUMSETTNGS_H
 |