ggwave : add default constructor

This commit is contained in:
Georgi Gerganov
2022-06-11 19:52:25 +03:00
parent 4a21ad667c
commit ca84180f22
9 changed files with 105 additions and 99 deletions

View File

@@ -122,7 +122,7 @@ int ggwave_encode(
}
{
auto pSrc = (const char *) ggWave->txData();
auto pSrc = (const char *) ggWave->txWaveform();
auto pDst = ( char *) waveformBuffer;
memcpy(pDst, pSrc, nBytes);
}
@@ -1023,35 +1023,11 @@ uint32_t GGWave::encode() {
m_tx.lastAmplitudeSize = offset;
// the encoded waveform can be accessed via the txData() method
// the encoded waveform can be accessed via the txWaveform() method
// we return the size of the waveform in bytes:
return offset*m_sampleSizeOut;
}
const void * GGWave::txData() const {
if (m_isTxEnabled == false) {
ggprintf("Tx is disabled - cannot transmit data with this GGWave instance\n");
return nullptr;
}
switch (m_sampleFormatOut) {
case GGWAVE_SAMPLE_FORMAT_UNDEFINED: break;
case GGWAVE_SAMPLE_FORMAT_I16:
{
return m_tx.outputI16.data();
} break;
case GGWAVE_SAMPLE_FORMAT_U8:
case GGWAVE_SAMPLE_FORMAT_I8:
case GGWAVE_SAMPLE_FORMAT_U16:
case GGWAVE_SAMPLE_FORMAT_F32:
{
return m_tx.outputTmp.data();
} break;
}
return nullptr;
}
bool GGWave::decode(const void * data, uint32_t nBytes) {
if (m_isRxEnabled == false) {
ggprintf("Rx is disabled - cannot receive data with this GGWave instance\n");
@@ -1213,6 +1189,25 @@ int GGWave::heapSize() const { return m_heapSize; }
// Tx
//
const void * GGWave::txWaveform() const {
switch (m_sampleFormatOut) {
case GGWAVE_SAMPLE_FORMAT_UNDEFINED: break;
case GGWAVE_SAMPLE_FORMAT_I16:
{
return m_tx.outputI16.data();
} break;
case GGWAVE_SAMPLE_FORMAT_U8:
case GGWAVE_SAMPLE_FORMAT_I8:
case GGWAVE_SAMPLE_FORMAT_U16:
case GGWAVE_SAMPLE_FORMAT_F32:
{
return m_tx.outputTmp.data();
} break;
}
return nullptr;
}
const GGWave::Tones GGWave::txTones() const { return { m_tx.tones.data(), m_tx.nTones }; }
bool GGWave::txHasData() const { return m_tx.hasData; }