mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 08:37:59 +08:00
ggwave : add DSS test + remove OperatingMode enum
This commit is contained in:
@@ -225,8 +225,8 @@ bool GGWave_init(
|
||||
if (reinit) {
|
||||
if (g_ggWave) delete g_ggWave;
|
||||
|
||||
ggwave_OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode = ggwave_OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
g_ggWave = new GGWave({
|
||||
payloadLength,
|
||||
|
||||
@@ -212,8 +212,8 @@ bool GGWave_init(
|
||||
}
|
||||
|
||||
if (reinit) {
|
||||
ggwave_OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode = ggwave_OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
g_ggWave = std::make_shared<GGWave>(GGWave::Parameters {
|
||||
payloadLength,
|
||||
|
||||
@@ -79,8 +79,8 @@ int main(int argc, char** argv) {
|
||||
|
||||
fprintf(stderr, "Generating waveform for message '%s' ...\n", message.c_str());
|
||||
|
||||
ggwave_OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode = ggwave_OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (useDSS) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
GGWave ggWave({
|
||||
payloadLength,
|
||||
|
||||
@@ -71,8 +71,8 @@ int main(int argc, char** argv) {
|
||||
const int txProtocolId = argm.count("t") == 0 ? 0 : std::stoi(argm.at("t"));
|
||||
const int payloadLength = argm.count("l") == 0 ? 16 : std::stoi(argm.at("l"));
|
||||
|
||||
ggwave_OperatingMode mode = ggwave_OperatingMode(GGWAVE_OPERATING_MODE_TX | GGWAVE_OPERATING_MODE_TX_ONLY_TONES);
|
||||
if (useDSS) mode = ggwave_OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_TX | GGWAVE_OPERATING_MODE_TX_ONLY_TONES;
|
||||
if (useDSS) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
GGWave ggWave({
|
||||
payloadLength,
|
||||
|
||||
@@ -224,8 +224,8 @@ bool GGWave_init(
|
||||
if (reinit) {
|
||||
if (g_ggWave) delete g_ggWave;
|
||||
|
||||
ggwave_OperatingMode mode = GGWAVE_OPERATING_MODE_RX;
|
||||
if (useDSS) mode = ggwave_OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX;
|
||||
if (useDSS) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
g_ggWave = new GGWave({
|
||||
payloadLength,
|
||||
|
||||
@@ -623,12 +623,12 @@ void updateCore() {
|
||||
if (inputCurrent.flags.needReinit) {
|
||||
static auto sampleRateInpOld = ggWave->sampleRateInp();
|
||||
static auto sampleRateOutOld = ggWave->sampleRateOut();
|
||||
GGWave::SampleFormat sampleFormatInpOld = ggWave->sampleFormatInp();
|
||||
GGWave::SampleFormat sampleFormatOutOld = ggWave->sampleFormatOut();
|
||||
auto sampleFormatInpOld = ggWave->sampleFormatInp();
|
||||
auto sampleFormatOutOld = ggWave->sampleFormatOut();
|
||||
auto rxProtocolsOld = ggWave->rxProtocols();
|
||||
|
||||
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
|
||||
if (inputCurrent.directSequenceSpread) mode = GGWave::OperatingMode(mode | GGWAVE_OPERATING_MODE_USE_DSS);
|
||||
if (inputCurrent.directSequenceSpread) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
GGWave::Parameters parameters {
|
||||
inputCurrent.payloadLength,
|
||||
|
||||
@@ -87,14 +87,14 @@ extern "C" {
|
||||
// GGWAVE_OPERATING_MODE_USE_DSS:
|
||||
// Enable the built-in Direct Sequence Spread (DSS) algorithm
|
||||
//
|
||||
typedef enum {
|
||||
enum {
|
||||
GGWAVE_OPERATING_MODE_RX = 1 << 1,
|
||||
GGWAVE_OPERATING_MODE_TX = 1 << 2,
|
||||
GGWAVE_OPERATING_MODE_RX_AND_TX = (GGWAVE_OPERATING_MODE_RX |
|
||||
GGWAVE_OPERATING_MODE_TX),
|
||||
GGWAVE_OPERATING_MODE_TX_ONLY_TONES = 1 << 3,
|
||||
GGWAVE_OPERATING_MODE_USE_DSS = 1 << 4,
|
||||
} ggwave_OperatingMode;
|
||||
};
|
||||
|
||||
// GGWave instance parameters
|
||||
//
|
||||
@@ -123,15 +123,15 @@ extern "C" {
|
||||
// not be allocated.
|
||||
//
|
||||
typedef struct {
|
||||
int payloadLength; // payload length
|
||||
float sampleRateInp; // capture sample rate
|
||||
float sampleRateOut; // playback sample rate
|
||||
float sampleRate; // the operating sample rate
|
||||
int samplesPerFrame; // number of samples per audio frame
|
||||
float soundMarkerThreshold; // sound marker detection threshold
|
||||
ggwave_SampleFormat sampleFormatInp; // format of the captured audio samples
|
||||
ggwave_SampleFormat sampleFormatOut; // format of the playback audio samples
|
||||
ggwave_OperatingMode operatingMode; // operating mode
|
||||
int payloadLength; // payload length
|
||||
float sampleRateInp; // capture sample rate
|
||||
float sampleRateOut; // playback sample rate
|
||||
float sampleRate; // the operating sample rate
|
||||
int samplesPerFrame; // number of samples per audio frame
|
||||
float soundMarkerThreshold; // sound marker detection threshold
|
||||
ggwave_SampleFormat sampleFormatInp; // format of the captured audio samples
|
||||
ggwave_SampleFormat sampleFormatOut; // format of the playback audio samples
|
||||
int operatingMode; // operating mode
|
||||
} ggwave_Parameters;
|
||||
|
||||
// GGWave instances are identified with an integer and are stored
|
||||
@@ -415,7 +415,7 @@ public:
|
||||
using ProtocolId = ggwave_ProtocolId;
|
||||
using TxProtocolId = ggwave_ProtocolId;
|
||||
using RxProtocolId = ggwave_ProtocolId;
|
||||
using OperatingMode = ggwave_OperatingMode;
|
||||
using OperatingMode = int; // ggwave_OperatingMode;
|
||||
|
||||
struct Protocol {
|
||||
const char * name; // string identifier of the protocol
|
||||
|
||||
@@ -644,7 +644,7 @@ const GGWave::Parameters & GGWave::getDefaultParameters() {
|
||||
kDefaultSoundMarkerThreshold,
|
||||
GGWAVE_SAMPLE_FORMAT_F32,
|
||||
GGWAVE_SAMPLE_FORMAT_F32,
|
||||
(ggwave_OperatingMode) (GGWAVE_OPERATING_MODE_RX | GGWAVE_OPERATING_MODE_TX),
|
||||
GGWAVE_OPERATING_MODE_RX | GGWAVE_OPERATING_MODE_TX,
|
||||
};
|
||||
|
||||
return result;
|
||||
|
||||
@@ -265,6 +265,7 @@ int main(int argc, char ** argv) {
|
||||
auto parameters = GGWave::getDefaultParameters();
|
||||
parameters.sampleFormatInp = formatInp;
|
||||
parameters.sampleFormatOut = formatOut;
|
||||
if (rand() % 2 == 0) parameters.operatingMode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
GGWave instance(parameters);
|
||||
instance.rxProtocols().only(GGWave::ProtocolId(protocolId));
|
||||
|
||||
@@ -292,6 +293,7 @@ int main(int argc, char ** argv) {
|
||||
parameters.payloadLength = length;
|
||||
parameters.sampleFormatInp = formatInp;
|
||||
parameters.sampleFormatOut = formatOut;
|
||||
if (rand() % 2 == 0) parameters.operatingMode |= GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
GGWave instance(parameters);
|
||||
instance.rxProtocols().only(GGWave::ProtocolId(protocolId));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user