ggwave : add default samples per frame

This commit is contained in:
Georgi Gerganov
2021-01-16 18:39:11 +02:00
parent 9fe9a0240e
commit 94978e679a
3 changed files with 8 additions and 1 deletions

View File

@@ -227,7 +227,7 @@ bool GGWave_init(
g_ggWave = new GGWave( g_ggWave = new GGWave(
g_obtainedSpecIn.freq, g_obtainedSpecIn.freq,
g_obtainedSpecOut.freq, g_obtainedSpecOut.freq,
1024, GGWave::kDefaultSamplesPerFrame,
sampleSizeBytesIn, sampleSizeBytesIn,
sampleSizeBytesOut); sampleSizeBytesOut);
} }

View File

@@ -7,6 +7,7 @@
class GGWave { class GGWave {
public: public:
static constexpr auto kBaseSampleRate = 48000.0; static constexpr auto kBaseSampleRate = 48000.0;
static constexpr auto kDefaultSamplesPerFrame = 1024;
static constexpr auto kMaxSamplesPerFrame = 1024; static constexpr auto kMaxSamplesPerFrame = 1024;
static constexpr auto kMaxDataBits = 256; static constexpr auto kMaxDataBits = 256;
static constexpr auto kMaxDataSize = 256; static constexpr auto kMaxDataSize = 256;
@@ -54,6 +55,7 @@ public:
int samplesPerFrame, int samplesPerFrame,
int sampleSizeBytesIn, int sampleSizeBytesIn,
int sampleSizeBytesOut); int sampleSizeBytesOut);
~GGWave(); ~GGWave();
bool init(int textLength, const char * stext, const TxProtocol & aProtocol, const int volume); bool init(int textLength, const char * stext, const TxProtocol & aProtocol, const int volume);

View File

@@ -5,6 +5,7 @@
#include <chrono> #include <chrono>
#include <algorithm> #include <algorithm>
#include <random> #include <random>
#include <stdexcept>
namespace { namespace {
@@ -163,6 +164,10 @@ GGWave::GGWave(
m_outputBlock(kMaxSamplesPerFrame), m_outputBlock(kMaxSamplesPerFrame),
m_outputBlock16(kMaxRecordedFrames*kMaxSamplesPerFrame) m_outputBlock16(kMaxRecordedFrames*kMaxSamplesPerFrame)
{ {
if (samplesPerFrame > kMaxSamplesPerFrame) {
throw std::runtime_error("Invalid samples per frame");
}
init(0, "", getDefultTxProtocol(), 0); init(0, "", getDefultTxProtocol(), 0);
} }