2017-02-23 02:18:56 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 F4HKW //
|
|
|
|
// for F4EXB / SDRAngel //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_ATVDEMOD_H
|
|
|
|
#define INCLUDE_ATVDEMOD_H
|
|
|
|
|
|
|
|
#include <dsp/basebandsamplesink.h>
|
|
|
|
#include <dsp/devicesamplesource.h>
|
|
|
|
#include <dsp/dspcommands.h>
|
|
|
|
#include <dsp/downchannelizer.h>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
#include <vector>
|
|
|
|
#include "dsp/nco.h"
|
|
|
|
#include "dsp/interpolator.h"
|
|
|
|
#include "dsp/movingaverage.h"
|
|
|
|
#include "dsp/agc.h"
|
|
|
|
#include "audio/audiofifo.h"
|
|
|
|
#include "util/message.h"
|
|
|
|
#include "atvscreen.h"
|
|
|
|
|
|
|
|
|
|
|
|
class ATVDemod : public BasebandSampleSink
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-03-16 15:45:31 -04:00
|
|
|
enum ATVModulation {
|
|
|
|
ATV_FM1,
|
2017-03-16 15:57:00 -04:00
|
|
|
ATV_FM2,
|
|
|
|
ATV_AM
|
2017-03-16 15:45:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ATVConfig
|
|
|
|
{
|
|
|
|
int m_intMsps;
|
|
|
|
int m_intLineDurationUs;
|
|
|
|
int m_intTopDurationUs;
|
|
|
|
int m_intFramePerS;
|
|
|
|
int m_intPercentOfRowsToDisplay;
|
|
|
|
float m_fltVoltLevelSynchroTop;
|
|
|
|
float m_fltVoltLevelSynchroBlack;
|
|
|
|
ATVModulation m_enmModulation;
|
|
|
|
bool m_blnHSync;
|
|
|
|
bool m_blnVSync;
|
|
|
|
|
|
|
|
ATVConfig() :
|
|
|
|
m_intMsps(0),
|
|
|
|
m_intLineDurationUs(0),
|
|
|
|
m_intTopDurationUs(0),
|
|
|
|
m_intFramePerS(0),
|
|
|
|
m_intPercentOfRowsToDisplay(0),
|
|
|
|
m_fltVoltLevelSynchroTop(0),
|
|
|
|
m_fltVoltLevelSynchroBlack(0),
|
|
|
|
m_enmModulation(ATV_FM1),
|
|
|
|
m_blnHSync(false),
|
|
|
|
m_blnVSync(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
ATVDemod();
|
|
|
|
~ATVDemod();
|
|
|
|
|
2017-02-25 01:12:41 -05:00
|
|
|
void configure(MessageQueue* objMessageQueue,
|
|
|
|
int intLineDurationUs,
|
|
|
|
int intTopDurationUs,
|
|
|
|
int intFramePerS,
|
|
|
|
int intPercentOfRowsToDisplay,
|
|
|
|
float fltVoltLevelSynchroTop,
|
|
|
|
float fltVoltLevelSynchroBlack,
|
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync);
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
|
|
|
bool SetATVScreen(ATVScreen *objScreen);
|
2017-02-25 01:12:41 -05:00
|
|
|
void InitATVParameters(int intMsps,
|
|
|
|
int intLineDurationUs,
|
|
|
|
int intTopDurationUs,
|
|
|
|
int intFramePerS,
|
|
|
|
int intPercentOfRowsToDisplay,
|
|
|
|
float fltVoltLevelSynchroTop,
|
|
|
|
float fltVoltLevelSynchroBlack,
|
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync);
|
2017-02-23 02:18:56 -05:00
|
|
|
int GetSampleRate();
|
2017-03-16 13:56:20 -04:00
|
|
|
double getMagSq() const { return m_objMagSqAverage.average(); } //!< Beware this is scaled to 2^30
|
2017-02-23 02:18:56 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//*************** ATV PARAMETERS ***************
|
|
|
|
ATVScreen * m_objRegisteredATVScreen;
|
|
|
|
|
|
|
|
int m_intNumberSamplePerLine;
|
|
|
|
int m_intNumberSamplePerTop;
|
|
|
|
int m_intNumberOfLines;
|
|
|
|
bool m_blnInitialized;
|
|
|
|
int m_intNumberOfRowsToDisplay;
|
|
|
|
|
|
|
|
float m_fltLevelSynchroTop;
|
|
|
|
float m_fltLevelSynchroBlack;
|
|
|
|
|
|
|
|
ATVModulation m_enmModulation;
|
|
|
|
|
|
|
|
//*************** PROCESSING ***************
|
|
|
|
|
|
|
|
int m_intImageIndex;
|
|
|
|
int m_intRowsLimit;
|
|
|
|
int m_intSynchroPoints;
|
|
|
|
|
|
|
|
bool m_blnSynchroDetected;
|
2017-02-24 17:25:09 -05:00
|
|
|
bool m_blnLineSynchronized;
|
2017-02-23 02:18:56 -05:00
|
|
|
bool m_blnImageDetecting;
|
|
|
|
bool m_blnVerticalSynchroDetected;
|
|
|
|
|
|
|
|
float m_fltAmpLineAverage;
|
|
|
|
|
|
|
|
float m_fltEffMin;
|
|
|
|
float m_fltEffMax;
|
|
|
|
|
|
|
|
float m_fltAmpMin;
|
|
|
|
float m_fltAmpMax;
|
|
|
|
float m_fltAmpDelta;
|
|
|
|
|
|
|
|
float m_fltBufferI[6];
|
|
|
|
float m_fltBufferQ[6];
|
|
|
|
|
|
|
|
int m_intColIndex;
|
|
|
|
int m_intRowIndex;
|
|
|
|
|
2017-03-16 13:56:20 -04:00
|
|
|
//*************** RF ***************
|
|
|
|
|
|
|
|
MovingAverage<double> m_objMagSqAverage;
|
|
|
|
|
2017-02-23 02:18:56 -05:00
|
|
|
//QElapsedTimer m_objTimer;
|
|
|
|
private:
|
|
|
|
|
|
|
|
class MsgConfigureATVDemod : public Message
|
|
|
|
{
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2017-02-25 01:12:41 -05:00
|
|
|
static MsgConfigureATVDemod* create(int intLineDurationUs,
|
|
|
|
int intTopDurationUs,
|
|
|
|
int intFramePerS,
|
|
|
|
int intPercentOfRowsToDisplay,
|
|
|
|
float fltVoltLevelSynchroTop,
|
|
|
|
float fltVoltLevelSynchroBlack,
|
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync)
|
2017-02-23 02:18:56 -05:00
|
|
|
{
|
2017-02-25 01:12:41 -05:00
|
|
|
return new MsgConfigureATVDemod(intLineDurationUs,
|
|
|
|
intTopDurationUs,
|
|
|
|
intFramePerS,
|
|
|
|
intPercentOfRowsToDisplay,
|
|
|
|
fltVoltLevelSynchroTop,
|
|
|
|
fltVoltLevelSynchroBlack,
|
|
|
|
enmModulation,
|
|
|
|
blnHSync,
|
|
|
|
blnVSync);
|
2017-02-23 02:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ATVConfig m_objMsgConfig;
|
|
|
|
|
|
|
|
private:
|
2017-02-25 01:12:41 -05:00
|
|
|
MsgConfigureATVDemod(int intLineDurationUs,
|
|
|
|
int intTopDurationUs,
|
|
|
|
int intFramePerS,
|
|
|
|
int intPercentOfRowsToDisplay,
|
|
|
|
float fltVoltLevelSynchroTop,
|
|
|
|
float fltVoltLevelSynchroBlack,
|
|
|
|
ATVModulation enmModulation,
|
|
|
|
bool blnHSync,
|
|
|
|
bool blnVSync) :
|
2017-02-23 02:18:56 -05:00
|
|
|
Message()
|
|
|
|
{
|
|
|
|
m_objMsgConfig.m_enmModulation = enmModulation;
|
|
|
|
m_objMsgConfig.m_fltVoltLevelSynchroBlack = fltVoltLevelSynchroBlack;
|
|
|
|
m_objMsgConfig.m_fltVoltLevelSynchroTop = fltVoltLevelSynchroTop;
|
|
|
|
m_objMsgConfig.m_intFramePerS = intFramePerS;
|
|
|
|
m_objMsgConfig.m_intLineDurationUs = intLineDurationUs;
|
|
|
|
m_objMsgConfig.m_intTopDurationUs = intTopDurationUs;
|
|
|
|
m_objMsgConfig.m_intPercentOfRowsToDisplay = intPercentOfRowsToDisplay;
|
|
|
|
m_objMsgConfig.m_blnHSync = blnHSync;
|
|
|
|
m_objMsgConfig.m_blnVSync = blnVSync;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ATVConfig m_objRunning;
|
|
|
|
|
|
|
|
QMutex m_objSettingsMutex;
|
|
|
|
|
|
|
|
void ApplySettings();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_ATVDEMOD_H
|