-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60221ad
commit 38b3b28
Showing
19 changed files
with
311 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#pragma once | ||
#include "../multirate/rrc_interpolator.h" | ||
#include "quadrature.h" | ||
|
||
namespace dsp::mod { | ||
class GFSK : public Processor<float, complex_t> { | ||
using base_type = Processor<float, complex_t>; | ||
public: | ||
GFSK() {} | ||
|
||
GFSK(stream<float>* in, double symbolrate, double samplerate, double rrcBeta, int rrcTapCount, double deviation) { | ||
init(in, symbolrate, samplerate, rrcBeta, rrcTapCount, deviation); | ||
} | ||
|
||
void init(stream<float>* in, double symbolrate, double samplerate, double rrcBeta, int rrcTapCount, double deviation) { | ||
_samplerate = samplerate; | ||
_deviation = deviation; | ||
|
||
interp.init(NULL, symbolrate, _samplerate, rrcBeta, rrcTapCount); | ||
mod.init(NULL, _deviation, _samplerate); | ||
|
||
base_type::init(in); | ||
} | ||
|
||
void setRates(double symbolrate, double samplerate) { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
base_type::tempStop(); | ||
_samplerate = samplerate; | ||
interp.setRates(symbolrate, _samplerate); | ||
mod.setDeviation(_deviation, _samplerate); | ||
base_type::tempStart(); | ||
} | ||
|
||
void setRRCParams(double rrcBeta, int rrcTapCount) { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
base_type::tempStop(); | ||
interp.setRRCParam(rrcBeta, rrcTapCount); | ||
base_type::tempStart(); | ||
} | ||
|
||
void setDeviation(double deviation) { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
_deviation = deviation; | ||
mod.setDeviation(_deviation, _samplerate); | ||
} | ||
|
||
void reset() { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
base_type::tempStop(); | ||
interp.reset(); | ||
mod.reset(); | ||
base_type::tempStart(); | ||
} | ||
|
||
inline int process(int count, const float* in, complex_t* out) { | ||
count = interp.process(count, in, interp.out.writeBuf); | ||
mod.process(count, interp.out.writeBuf, out); | ||
return count; | ||
} | ||
|
||
int run() { | ||
int count = base_type::_in->read(); | ||
if (count < 0) { return -1; } | ||
|
||
int outCount = process(count, base_type::_in->readBuf, base_type::out.writeBuf); | ||
|
||
// Swap if some data was generated | ||
base_type::_in->flush(); | ||
if (outCount) { | ||
if (!base_type::out.swap(outCount)) { return -1; } | ||
} | ||
return outCount; | ||
} | ||
|
||
private: | ||
double _samplerate; | ||
double _deviation; | ||
|
||
multirate::RRCInterpolator<float> interp; | ||
Quadrature mod; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#include "../multirate/rrc_interpolator.h" | ||
|
||
namespace dsp::mod { | ||
typedef multirate::RRCInterpolator<complex_t> PSK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#pragma once | ||
#include "../processor.h" | ||
#include "../math/phasor.h" | ||
#include "../math/normalize_phase.h" | ||
#include "../math/hz_to_rads.h" | ||
|
||
namespace dsp::mod { | ||
class Quadrature : Processor<float, complex_t> { | ||
using base_type = Processor<float, complex_t>; | ||
public: | ||
Quadrature() {} | ||
|
||
Quadrature(stream<float>* in, double deviation) { init(in, deviation); } | ||
|
||
Quadrature(stream<float>* in, double deviation, double samplerate) { init(in, deviation, samplerate); } | ||
|
||
void init(stream<float>* in, double deviation) { | ||
_deviation = deviation; | ||
base_type::init(in); | ||
} | ||
|
||
void init(stream<float>* in, double deviation, double samplerate) { | ||
init(in, math::hzToRads(deviation, samplerate)); | ||
} | ||
|
||
void setDeviation(double deviation) { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
_deviation = deviation; | ||
} | ||
|
||
void setDeviation(double deviation, double samplerate) { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
_deviation = math::hzToRads(deviation, samplerate); | ||
} | ||
|
||
void reset() { | ||
assert(base_type::_block_init); | ||
std::lock_guard<std::recursive_mutex> lck(base_type::ctrlMtx); | ||
phase = 0.0f; | ||
} | ||
|
||
inline int process(int count, const float* in, complex_t* out) { | ||
for (int i = 0; i < count; i++) { | ||
phase = math::normalizePhase(phase + (_deviation * in[i])); | ||
out[i] = math::phasor(phase); | ||
} | ||
return count; | ||
} | ||
|
||
virtual int run() { | ||
int count = base_type::_in->read(); | ||
if (count < 0) { return -1; } | ||
|
||
process(count, base_type::_in->readBuf, base_type::out.writeBuf); | ||
|
||
base_type::_in->flush(); | ||
if (!base_type::out.swap(count)) { return -1; } | ||
return count; | ||
} | ||
|
||
private: | ||
float _deviation; | ||
float phase = 0.0f; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.