mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-04-20 21:26:30 +08:00
ggwave : do not compute Tx amplitudes when Tx only tones
This commit is contained in:
@@ -700,34 +700,6 @@ bool GGWave::encode(const CBWaveformOut & cbWaveformOut) {
|
|||||||
m_resampler->reset();
|
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 nECCBytesPerTx = getECCBytesForLength(m_tx->txDataLength);
|
||||||
const int sendDataLength = m_tx->txDataLength + m_encodedDataOffset;
|
const int sendDataLength = m_tx->txDataLength + m_encodedDataOffset;
|
||||||
const int totalBytes = sendDataLength + nECCBytesPerTx;
|
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;
|
int frameId = 0;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
const float factor = m_sampleRate/m_sampleRateOut;
|
const float factor = m_sampleRate/m_sampleRateOut;
|
||||||
|
|||||||
Reference in New Issue
Block a user