mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-05-10 10:57:39 +08:00
ggwave : add default samples per frame
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user