From fb2dcb3a37877d300355555e5e607fe2ac5b8d31 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 29 May 2022 17:58:07 +0300 Subject: [PATCH] ggwave : do not compute Tx amplitudes when Tx only tones --- src/ggwave.cpp | 59 ++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/ggwave.cpp b/src/ggwave.cpp index ecbf396..e4fc339 100644 --- a/src/ggwave.cpp +++ b/src/ggwave.cpp @@ -700,34 +700,6 @@ bool GGWave::encode(const CBWaveformOut & cbWaveformOut) { m_resampler->reset(); } - for (int k = 0; k < (int) m_tx->phaseOffsets.size(); ++k) { - m_tx->phaseOffsets[k] = (M_PI*k)/(m_tx->txProtocol.nDataBitsPerTx()); - } - - // note : what is the purpose of this shuffle ? I forgot .. :( - //std::random_device rd; - //std::mt19937 g(rd()); - - //std::shuffle(phaseOffsets.begin(), phaseOffsets.end(), g); - - for (int k = 0; k < (int) m_tx->dataBits.size(); ++k) { - const double freq = bitFreq(m_tx->txProtocol, k); - - const double phaseOffset = m_tx->phaseOffsets[k]; - const double curHzPerSample = m_hzPerSample; - const double curIHzPerSample = 1.0/curHzPerSample; - - for (int i = 0; i < m_samplesPerFrame; i++) { - const double curi = i; - m_tx->bit1Amplitude[k][i] = std::sin((2.0*M_PI)*(curi*m_isamplesPerFrame)*(freq*curIHzPerSample) + phaseOffset); - } - - for (int i = 0; i < m_samplesPerFrame; i++) { - const double curi = i; - m_tx->bit0Amplitude[k][i] = std::sin((2.0*M_PI)*(curi*m_isamplesPerFrame)*((freq + m_hzPerSample*m_freqDelta_bin)*curIHzPerSample) + phaseOffset); - } - } - const int nECCBytesPerTx = getECCBytesForLength(m_tx->txDataLength); const int sendDataLength = m_tx->txDataLength + m_encodedDataOffset; const int totalBytes = sendDataLength + nECCBytesPerTx; @@ -813,6 +785,37 @@ bool GGWave::encode(const CBWaveformOut & cbWaveformOut) { } } + // compute Tx data + { + for (int k = 0; k < (int) m_tx->phaseOffsets.size(); ++k) { + m_tx->phaseOffsets[k] = (M_PI*k)/(m_tx->txProtocol.nDataBitsPerTx()); + } + + // note : what is the purpose of this shuffle ? I forgot .. :( + //std::random_device rd; + //std::mt19937 g(rd()); + + //std::shuffle(phaseOffsets.begin(), phaseOffsets.end(), g); + + for (int k = 0; k < (int) m_tx->dataBits.size(); ++k) { + const double freq = bitFreq(m_tx->txProtocol, k); + + const double phaseOffset = m_tx->phaseOffsets[k]; + const double curHzPerSample = m_hzPerSample; + const double curIHzPerSample = 1.0/curHzPerSample; + + for (int i = 0; i < m_samplesPerFrame; i++) { + const double curi = i; + m_tx->bit1Amplitude[k][i] = std::sin((2.0*M_PI)*(curi*m_isamplesPerFrame)*(freq*curIHzPerSample) + phaseOffset); + } + + for (int i = 0; i < m_samplesPerFrame; i++) { + const double curi = i; + m_tx->bit0Amplitude[k][i] = std::sin((2.0*M_PI)*(curi*m_isamplesPerFrame)*((freq + m_hzPerSample*m_freqDelta_bin)*curIHzPerSample) + phaseOffset); + } + } + } + int frameId = 0; uint32_t offset = 0; const float factor = m_sampleRate/m_sampleRateOut;