mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-05 06:37:51 -04:00
Test source: added sawtooth pattern
This commit is contained in:
parent
2958e1adba
commit
faf428ed3d
@ -482,7 +482,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pul</string>
|
<string>P0</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>P1</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -354,8 +354,15 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for
|
|||||||
|
|
||||||
if ((m_settings.m_modulation != settings.m_modulation) || force)
|
if ((m_settings.m_modulation != settings.m_modulation) || force)
|
||||||
{
|
{
|
||||||
if (m_testSourceThread != 0) {
|
if (m_testSourceThread != 0)
|
||||||
|
{
|
||||||
m_testSourceThread->setModulation(settings.m_modulation);
|
m_testSourceThread->setModulation(settings.m_modulation);
|
||||||
|
|
||||||
|
if (settings.m_modulation == TestSourceSettings::ModulationPattern0) {
|
||||||
|
m_testSourceThread->setPattern0();
|
||||||
|
} else if (settings.m_modulation == TestSourceSettings::ModulationPattern1) {
|
||||||
|
m_testSourceThread->setPattern1();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ struct TestSourceSettings {
|
|||||||
ModulationNone,
|
ModulationNone,
|
||||||
ModulationAM,
|
ModulationAM,
|
||||||
ModulationFM,
|
ModulationFM,
|
||||||
ModulationPulse,
|
ModulationPattern0,
|
||||||
|
ModulationPattern1,
|
||||||
ModulationLast
|
ModulationLast
|
||||||
} Modulation;
|
} Modulation;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ void TestSourceThread::generate(quint32 chunksize)
|
|||||||
m_buf[i++] = (int16_t) (im * (float) m_amplitudeBitsQ);
|
m_buf[i++] = (int16_t) (im * (float) m_amplitudeBitsQ);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TestSourceSettings::ModulationPulse:
|
case TestSourceSettings::ModulationPattern0: // binary pattern
|
||||||
{
|
{
|
||||||
if (m_pulseSampleCount < m_pulseWidth) // sync pattern: 0
|
if (m_pulseSampleCount < m_pulseWidth) // sync pattern: 0
|
||||||
{
|
{
|
||||||
@ -288,7 +288,7 @@ void TestSourceThread::generate(quint32 chunksize)
|
|||||||
{
|
{
|
||||||
uint32_t patPulseSampleCount = m_pulseSampleCount - 3*m_pulseWidth;
|
uint32_t patPulseSampleCount = m_pulseSampleCount - 3*m_pulseWidth;
|
||||||
uint32_t patPulseIndex = patPulseSampleCount / m_pulseWidth;
|
uint32_t patPulseIndex = patPulseSampleCount / m_pulseWidth;
|
||||||
float patFigure = (m_pulsePatternCount & (1<<patPulseIndex)) != 0 ? 0.1 : 0.0; // make binary pattern -20dB vs sync pattern
|
float patFigure = (m_pulsePatternCount & (1<<patPulseIndex)) != 0 ? 0.3 : 0.0; // make binary pattern ~-10dB vs sync pattern
|
||||||
m_buf[i++] = (int16_t) (patFigure * (float) m_amplitudeBitsI) + m_amplitudeBitsDC;
|
m_buf[i++] = (int16_t) (patFigure * (float) m_amplitudeBitsI) + m_amplitudeBitsDC;
|
||||||
m_buf[i++] = (int16_t) (patFigure * (float) m_phaseImbalance * m_amplitudeBitsQ);
|
m_buf[i++] = (int16_t) (patFigure * (float) m_phaseImbalance * m_amplitudeBitsQ);
|
||||||
}
|
}
|
||||||
@ -309,6 +309,21 @@ void TestSourceThread::generate(quint32 chunksize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TestSourceSettings::ModulationPattern1: // sawtooth pattern
|
||||||
|
{
|
||||||
|
Real re, im;
|
||||||
|
re = (float) (m_pulseWidth - m_pulseSampleCount) / (float) m_pulseWidth;
|
||||||
|
im = m_phaseImbalance*re;
|
||||||
|
m_buf[i++] = (int16_t) (re * (float) m_amplitudeBitsI) + m_amplitudeBitsDC;
|
||||||
|
m_buf[i++] = (int16_t) (im * (float) m_amplitudeBitsQ);
|
||||||
|
|
||||||
|
if (m_pulseSampleCount < m_pulseWidth - 1) {
|
||||||
|
m_pulseSampleCount++;
|
||||||
|
} else {
|
||||||
|
m_pulseSampleCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case TestSourceSettings::ModulationNone:
|
case TestSourceSettings::ModulationNone:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@ -389,3 +404,18 @@ void TestSourceThread::handleInputMessages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestSourceThread::setPattern0()
|
||||||
|
{
|
||||||
|
m_pulseWidth = 150;
|
||||||
|
m_pulseSampleCount = 0;
|
||||||
|
m_pulsePatternCount = 0;
|
||||||
|
m_pulsePatternCycle = 8;
|
||||||
|
m_pulsePatternPlaces = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestSourceThread::setPattern1()
|
||||||
|
{
|
||||||
|
m_pulseWidth = 1000;
|
||||||
|
m_pulseSampleCount = 0;
|
||||||
|
}
|
||||||
|
@ -75,6 +75,8 @@ public:
|
|||||||
void setModulation(TestSourceSettings::Modulation modulation);
|
void setModulation(TestSourceSettings::Modulation modulation);
|
||||||
void setAMModulation(float amModulation);
|
void setAMModulation(float amModulation);
|
||||||
void setFMDeviation(float deviation);
|
void setFMDeviation(float deviation);
|
||||||
|
void setPattern0();
|
||||||
|
void setPattern1();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex m_startWaitMutex;
|
QMutex m_startWaitMutex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user