mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
ATV Modulator: fixed calculation on sample rate change
This commit is contained in:
parent
aa8ef5e791
commit
eb47a29f4a
@ -84,12 +84,10 @@ ATVMod::ATVMod() :
|
|||||||
m_DSBFilterBuffer = new Complex[m_ssbFftLen];
|
m_DSBFilterBuffer = new Complex[m_ssbFftLen];
|
||||||
memset(m_DSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen));
|
memset(m_DSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen));
|
||||||
|
|
||||||
applyStandard();
|
|
||||||
|
|
||||||
m_interpolatorDistanceRemain = 0.0f;
|
m_interpolatorDistanceRemain = 0.0f;
|
||||||
m_interpolatorDistance = 1.0f;
|
m_interpolatorDistance = 1.0f;
|
||||||
|
|
||||||
apply(true);
|
apply(true); // does applyStandard() too;
|
||||||
|
|
||||||
m_movingAverage.resize(16, 0);
|
m_movingAverage.resize(16, 0);
|
||||||
}
|
}
|
||||||
@ -691,10 +689,19 @@ void ATVMod::apply(bool force)
|
|||||||
|| (m_config.m_atvModulation != m_running.m_atvModulation) || force)
|
|| (m_config.m_atvModulation != m_running.m_atvModulation) || force)
|
||||||
{
|
{
|
||||||
int rateUnits, nbPointsPerRateUnit;
|
int rateUnits, nbPointsPerRateUnit;
|
||||||
getBaseValues(m_config.m_nbLines * m_config.m_fps, rateUnits, nbPointsPerRateUnit);
|
getBaseValues(m_config.m_outputSampleRate, m_config.m_nbLines * m_config.m_fps, rateUnits, nbPointsPerRateUnit);
|
||||||
m_tvSampleRate = (m_config.m_outputSampleRate / rateUnits) * rateUnits; // make sure working sample rate is a multiple of rate units
|
m_tvSampleRate = (m_config.m_outputSampleRate / rateUnits) * rateUnits; // make sure working sample rate is a multiple of rate units
|
||||||
m_pointsPerLine = (m_tvSampleRate / rateUnits) * nbPointsPerRateUnit;
|
m_pointsPerLine = (m_tvSampleRate / rateUnits) * nbPointsPerRateUnit;
|
||||||
|
|
||||||
|
// qDebug() << "ATVMod::apply: "
|
||||||
|
// << " m_nbLines: " << m_config.m_nbLines
|
||||||
|
// << " m_fps: " << m_config.m_fps
|
||||||
|
// << " rateUnits: " << rateUnits
|
||||||
|
// << " nbPointsPerRateUnit: " << nbPointsPerRateUnit
|
||||||
|
// << " m_outputSampleRate: " << m_config.m_outputSampleRate
|
||||||
|
// << " m_tvSampleRate: " << m_tvSampleRate
|
||||||
|
// << " m_pointsPerTU: " << m_pointsPerTU;
|
||||||
|
|
||||||
m_settingsMutex.lock();
|
m_settingsMutex.lock();
|
||||||
|
|
||||||
if (m_tvSampleRate > 0)
|
if (m_tvSampleRate > 0)
|
||||||
@ -715,7 +722,7 @@ void ATVMod::apply(bool force)
|
|||||||
memset(m_SSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen>>1));
|
memset(m_SSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen>>1));
|
||||||
m_SSBFilterBufferIndex = 0;
|
m_SSBFilterBufferIndex = 0;
|
||||||
|
|
||||||
applyStandard(); // set all timings
|
applyStandard(rateUnits, nbPointsPerRateUnit); // set all timings
|
||||||
m_settingsMutex.unlock();
|
m_settingsMutex.unlock();
|
||||||
|
|
||||||
MsgReportEffectiveSampleRate *report;
|
MsgReportEffectiveSampleRate *report;
|
||||||
@ -767,17 +774,18 @@ void ATVMod::apply(bool force)
|
|||||||
m_running.m_forceDecimator = m_config.m_forceDecimator;
|
m_running.m_forceDecimator = m_config.m_forceDecimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATVMod::getBaseValues(int linesPerSecond, int& sampleRateUnits, int& nbPointsPerRateUnit)
|
void ATVMod::getBaseValues(int outputSampleRate, int linesPerSecond, int& sampleRateUnits, int& nbPointsPerRateUnit)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int maxPoints = outputSampleRate / linesPerSecond;
|
||||||
|
int i = maxPoints;
|
||||||
|
|
||||||
for (; i < 100; i++)
|
for (; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (((100+i) * linesPerSecond) % 1000 == 0)
|
if ((i * linesPerSecond) % 1000 == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbPointsPerRateUnit = (i == 100) ? 100 : 100+i;
|
nbPointsPerRateUnit = i;
|
||||||
sampleRateUnits = nbPointsPerRateUnit * linesPerSecond;
|
sampleRateUnits = nbPointsPerRateUnit * linesPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -798,10 +806,8 @@ float ATVMod::getRFBandwidthDivisor(ATVModulation modulation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATVMod::applyStandard()
|
void ATVMod::applyStandard(int rateUnits, int nbPointsPerRateUnit)
|
||||||
{
|
{
|
||||||
int rateUnits, nbPointsPerRateUnit;
|
|
||||||
getBaseValues(m_config.m_nbLines * m_config.m_fps, rateUnits, nbPointsPerRateUnit);
|
|
||||||
m_pointsPerTU = m_tvSampleRate / rateUnits; // TV sample rate is already set at a multiple of rate units
|
m_pointsPerTU = m_tvSampleRate / rateUnits; // TV sample rate is already set at a multiple of rate units
|
||||||
|
|
||||||
m_pointsPerSync = (uint32_t) roundf(4.7f * m_pointsPerTU); // normal sync pulse (4.7 us / rateUnits)
|
m_pointsPerSync = (uint32_t) roundf(4.7f * m_pointsPerTU); // normal sync pulse (4.7 us / rateUnits)
|
||||||
@ -819,6 +825,14 @@ void ATVMod::applyStandard()
|
|||||||
m_nbLines2 = (m_nbLines / 2) + 1;
|
m_nbLines2 = (m_nbLines / 2) + 1;
|
||||||
m_fps = m_config.m_fps * 1.0f;
|
m_fps = m_config.m_fps * 1.0f;
|
||||||
|
|
||||||
|
// qDebug() << "ATVMod::applyStandard: "
|
||||||
|
// << " m_nbLines: " << m_config.m_nbLines
|
||||||
|
// << " m_fps: " << m_config.m_fps
|
||||||
|
// << " rateUnits: " << rateUnits
|
||||||
|
// << " nbPointsPerRateUnit: " << nbPointsPerRateUnit
|
||||||
|
// << " m_tvSampleRate: " << m_tvSampleRate
|
||||||
|
// << " m_pointsPerTU: " << m_pointsPerTU;
|
||||||
|
|
||||||
switch(m_config.m_atvStd)
|
switch(m_config.m_atvStd)
|
||||||
{
|
{
|
||||||
case ATVStd405: // Follows loosely the 405 lines standard
|
case ATVStd405: // Follows loosely the 405 lines standard
|
||||||
|
@ -404,7 +404,7 @@ public:
|
|||||||
Real getMagSq() const { return m_movingAverage.average(); }
|
Real getMagSq() const { return m_movingAverage.average(); }
|
||||||
void getCameraNumbers(std::vector<int>& numbers);
|
void getCameraNumbers(std::vector<int>& numbers);
|
||||||
|
|
||||||
static void getBaseValues(int linesPerSecond, int& sampleRateUnits, int& nbPointsPerRateUnit);
|
static void getBaseValues(int outputSampleRate, int linesPerSecond, int& sampleRateUnits, int& nbPointsPerRateUnit);
|
||||||
static float getRFBandwidthDivisor(ATVModulation modulation);
|
static float getRFBandwidthDivisor(ATVModulation modulation);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -699,7 +699,7 @@ private:
|
|||||||
void modulateSample();
|
void modulateSample();
|
||||||
Complex& modulateSSB(Real& sample);
|
Complex& modulateSSB(Real& sample);
|
||||||
Complex& modulateVestigialSSB(Real& sample);
|
Complex& modulateVestigialSSB(Real& sample);
|
||||||
void applyStandard();
|
void applyStandard(int rateUnits, int nbPointsPerRateUnit);
|
||||||
void openImage(const QString& fileName);
|
void openImage(const QString& fileName);
|
||||||
void openVideo(const QString& fileName);
|
void openVideo(const QString& fileName);
|
||||||
void resizeImage();
|
void resizeImage();
|
||||||
|
Loading…
Reference in New Issue
Block a user