summaryrefslogtreecommitdiff
path: root/Modulator.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2019-04-29 22:08:59 +0200
committerChristoph Berg <myon@debian.org>2019-04-29 22:08:59 +0200
commitb7238399ea4f1ca51d8f7b8f9220af3da0913edf (patch)
tree9716c5c0a793b2f7cda83e9d8f840095a0e9358e /Modulator.cpp
parent200de07a95209a55d6019ba87f0abc78d302bf4c (diff)
New upstream version 2.1.0~rc5+repackupstream/2.1.0_rc5+repack
Diffstat (limited to 'Modulator.cpp')
-rw-r--r--Modulator.cpp45
1 files changed, 33 insertions, 12 deletions
diff --git a/Modulator.cpp b/Modulator.cpp
index a7564f6c..725de9e4 100644
--- a/Modulator.cpp
+++ b/Modulator.cpp
@@ -51,10 +51,10 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
// Time according to this computer which becomes our base time
qint64 ms0 = QDateTime::currentMSecsSinceEpoch() % 86400000;
- if (m_state != Idle)
- {
- stop ();
- }
+// qDebug() << "ModStart" << symbolsLength << framesPerSymbol
+// << frequency << toneSpacing;
+
+ if(m_state != Idle) stop ();
m_quickClose = false;
@@ -92,6 +92,14 @@ void Modulator::start (unsigned symbolsLength, double framesPerSymbol,
if (synchronize && !m_tuning && !m_bFastMode) {
m_silentFrames = m_ic + m_frameRate / (1000 / delay_ms) - (mstr * (m_frameRate / 1000));
}
+ if(symbolsLength==105 and framesPerSymbol==512
+ and (toneSpacing==12000.0/512.0 or toneSpacing==-2.0)) {
+//### FT4 parameters
+ m_ic=0;
+ m_silentFrames=0;
+ }
+// qDebug() << "Mod AA" << symbolsLength << framesPerSymbol << toneSpacing;
+// qDebug() << "Mod AB" << delay_ms << mstr << m_ic << m_silentFrames;
initialize (QIODevice::ReadOnly, channel);
Q_EMIT stateChanged ((m_state = (synchronize && m_silentFrames) ?
@@ -149,6 +157,8 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
qint16 * end (samples + numFrames * (bytesPerFrame () / sizeof (qint16)));
qint64 framesGenerated (0);
+// if(m_ic==0) qDebug() << "Modulator::readData" << 0.001*(QDateTime::currentMSecsSinceEpoch() % (1000*m_TRperiod));
+
switch (m_state)
{
case Synchronizing:
@@ -170,7 +180,7 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
case Active:
{
unsigned int isym=0;
-// qDebug() << "Mod A" << m_toneSpacing << m_ic;
+
if(!m_tuning) isym=m_ic/(4.0*m_nsps); // Actual fsample=48000
bool slowCwId=((isym >= m_symbolsLength) && (icw[0] > 0)) && (!m_bFastMode);
if(m_TRperiod==3) slowCwId=false;
@@ -181,6 +191,8 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
if(m_bFastMode and (icw[0]>0) and (tsec>(m_TRperiod-5.0))) fastCwId=true;
if(!m_bFastMode) m_nspd=2560; // 22.5 WPM
+// qDebug() << "Mod A" << m_ic << isym << tsec;
+
if(slowCwId or fastCwId) { // Transmit CW ID?
m_dphi = m_twoPi*m_frequency/m_frameRate;
if(m_bFastMode and !bCwId) {
@@ -252,10 +264,10 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
}
qint16 sample;
+
for (unsigned i = 0; i < numFrames && m_ic <= i1; ++i) {
isym=0;
- if(!m_tuning and m_TRperiod!=3) isym=m_ic / (4.0 * m_nsps); //Actual
- //fsample=48000
+ if(!m_tuning and m_TRperiod!=3) isym=m_ic/(4.0*m_nsps); //Actual fsample=48000
if(m_bFastMode) isym=isym%m_symbolsLength;
if (isym != m_isym0 || m_frequency != m_frequency0) {
if(itone[0]>=100) {
@@ -267,8 +279,6 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
m_toneFrequency0=m_frequency + itone[isym]*m_toneSpacing;
}
}
-// qDebug() << "Mod B" << m_bFastMode << m_ic << numFrames << isym << itone[isym]
-// << m_toneFrequency0 << m_nsps;
m_dphi = m_twoPi * m_toneFrequency0 / m_frameRate;
m_isym0 = isym;
m_frequency0 = m_frequency; //???
@@ -289,9 +299,12 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
if (m_ic > i1) m_amp = 0.0;
sample=qRound(m_amp*qSin(m_phi));
- if(m_toneSpacing < 0) sample=qRound(m_amp*foxcom_.wave[m_ic]);
-// if(m_ic < 100) qDebug() << "Mod C" << m_ic << m_amp << foxcom_.wave[m_ic] << sample;
+//Here's where we transmit from a precomputed wave[] array:
+ if(!m_tuning and (m_toneSpacing < 0)) {
+ m_amp=32767.0;
+ sample=qRound(m_amp*foxcom_.wave[m_ic]);
+ }
samples = load(postProcessSample(sample), samples);
++framesGenerated;
@@ -308,7 +321,15 @@ qint64 Modulator::readData (char * data, qint64 maxSize)
}
m_frequency0 = m_frequency;
- // done for this chunk - continue on next call
+// done for this chunk - continue on next call
+
+// qDebug() << "Mod B" << m_ic << i1 << 0.001*(QDateTime::currentMSecsSinceEpoch() % (1000*m_TRperiod));
+
+ while (samples != end) // pad block with silence
+ {
+ samples = load (0, samples);
+ ++framesGenerated;
+ }
return framesGenerated * bytesPerFrame ();
}
// fall through