Test source: added a square pattern

This commit is contained in:
f4exb 2018-10-25 13:53:58 +02:00
parent acbaa14dbd
commit f43c07b9e5
6 changed files with 49 additions and 13 deletions

View File

@ -89,6 +89,9 @@ This controls the generator sample rate in samples per second.
- **P1**: Pattern 1 is a sawtooth pattern
- Pulse width: 1000 samples
- Starts at full amplitude then amplitude decreases linearly down to zero
- **P2**: Pattern 2 is a 50% duty cycle square pattern
- Pulse width: 1000 samples
- Starts with a full amplitude pulse then down to zero for the duration of one pulse
<h3>5: Modulating tone frequency</h3>

View File

@ -490,6 +490,11 @@
<string>P1</string>
</property>
</item>
<item>
<property name="text">
<string>P2</string>
</property>
</item>
</widget>
</item>
<item>

View File

@ -362,6 +362,8 @@ bool TestSourceInput::applySettings(const TestSourceSettings& settings, bool for
m_testSourceThread->setPattern0();
} else if (settings.m_modulation == TestSourceSettings::ModulationPattern1) {
m_testSourceThread->setPattern1();
} else if (settings.m_modulation == TestSourceSettings::ModulationPattern2) {
m_testSourceThread->setPattern2();
}
}
}

View File

@ -39,6 +39,7 @@ struct TestSourceSettings {
ModulationFM,
ModulationPattern0,
ModulationPattern1,
ModulationPattern2,
ModulationLast
} Modulation;

View File

@ -324,6 +324,24 @@ void TestSourceThread::generate(quint32 chunksize)
}
}
break;
case TestSourceSettings::ModulationPattern2: // 50% duty cycle square pattern
{
if (m_pulseSampleCount < m_pulseWidth) // 1
{
m_buf[i++] = (int16_t) (m_amplitudeBitsI + m_amplitudeBitsDC);
m_buf[i++] = (int16_t) (m_phaseImbalance * (float) m_amplitudeBitsQ);
} else { // 0
m_buf[i++] = m_amplitudeBitsDC;
m_buf[i++] = 0;
}
if (m_pulseSampleCount < 2*m_pulseWidth - 1) {
m_pulseSampleCount++;
} else {
m_pulseSampleCount = 0;
}
}
break;
case TestSourceSettings::ModulationNone:
default:
{
@ -419,3 +437,9 @@ void TestSourceThread::setPattern1()
m_pulseWidth = 1000;
m_pulseSampleCount = 0;
}
void TestSourceThread::setPattern2()
{
m_pulseWidth = 1000;
m_pulseSampleCount = 0;
}

View File

@ -77,6 +77,7 @@ public:
void setFMDeviation(float deviation);
void setPattern0();
void setPattern1();
void setPattern2();
private:
QMutex m_startWaitMutex;