afsk.hh
#ifndef __SDR_AFSK_HH__
#define __SDR_AFSK_HH__
#include "node.hh"
namespace sdr {
class AFSK: public Sink<int16_t>, public Source
{
public:
typedef enum {
NORMAL,
TRANSITION
} Mode;
public:
AFSK(double baud=1200.0, double Fmark=1200.0, double Fspace=2200.0,
Mode mode=TRANSITION);
virtual ~AFSK();
virtual void config(const Config &src_cfg);
virtual void process(const Buffer<int16_t> &buffer, bool allow_overwrite);
protected:
inline double _getSymbol() {
std::complex<float> markSum(0), spaceSum(0);
for (size_t i=0; i<_corrLen; i++) {
markSum += _markHist[i];
spaceSum += _spaceHist[i];
}
double f = markSum.real()*markSum.real() +
markSum.imag()*markSum.imag() -
spaceSum.real()*spaceSum.real() -
spaceSum.imag()*spaceSum.imag();
return f;
}
protected:
float _sampleRate;
float _symbolRate;
float _baud;
float _Fmark;
float _Fspace;
Mode _mode;
uint32_t _corrLen;
uint32_t _lutIdx;
Buffer< std::complex<float> > _markLUT;
Buffer< std::complex<float> > _spaceLUT;
Buffer< std::complex<float> > _markHist;
Buffer< std::complex<float> > _spaceHist;
float _mu;
float _muIncr;
Buffer< float > _dl;
size_t _dl_idx;
Buffer<int16_t> _symbols;
size_t _symbolIdx;
int32_t _symSum;
int32_t _lastSymSum;
uint32_t _lastBits;
float _phase;
float _omega;
float _omegaMin;
float _omegaMax;
float _gainOmega;
Buffer<uint8_t> _buffer;
};
}
#endif // __SDR_AFSK_HH__
sdr::Config
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
sdr::AFSK::_markLUT
Buffer< std::complex< float > > _markLUT
Mark frequency FIR filter LUT.
Definition: afsk.hh:69
sdr::AFSK::~AFSK
virtual ~AFSK()
Destructor.
Definition: afsk.cc:15
sdr::AFSK::_symbolIdx
size_t _symbolIdx
Insertion index.
Definition: afsk.hh:90
sdr::Sink
Typed sink.
Definition: node.hh:192
sdr
Definition: afsk.hh:6
sdr::AFSK::_lutIdx
uint32_t _lutIdx
The current FIR filter LUT index.
Definition: afsk.hh:67
sdr::AFSK::_omegaMin
float _omegaMin
Maximum PLL phase speed.
Definition: afsk.hh:103
sdr::AFSK::_omega
float _omega
PLL phase speed.
Definition: afsk.hh:101
sdr::Source
Generic source class.
Definition: node.hh:213
sdr::AFSK::_lastSymSum
int32_t _lastSymSum
Sum of the last _corrLen symbols.
Definition: afsk.hh:94
sdr::AFSK::TRANSITION
Transition mode (i.e. transition -> 0, no transition -> 1).
Definition: afsk.hh:19
sdr::AFSK::_spaceLUT
Buffer< std::complex< float > > _spaceLUT
Space frequency FIR filter LUT.
Definition: afsk.hh:71
sdr::AFSK::_mu
float _mu
Symbol subsampling counter.
Definition: afsk.hh:79
sdr::AFSK::_dl
Buffer< float > _dl
Delay line for the 8-pole interpolation filter.
Definition: afsk.hh:83
sdr::AFSK::_Fmark
float _Fmark
Mark "tone" frequency.
Definition: afsk.hh:59
sdr::AFSK::_symbolRate
float _symbolRate
A multiple of the baud rate.
Definition: afsk.hh:55
sdr::AFSK::_phase
float _phase
Current PLL phase.
Definition: afsk.hh:99
sdr::AFSK
A simple (Audio) Frequency Shift Keying (AFSK) demodulator.
Definition: afsk.hh:13
sdr::AFSK::_buffer
Buffer< uint8_t > _buffer
Output buffer.
Definition: afsk.hh:110
sdr::AFSK::_Fspace
float _Fspace
Space "tone" frequency.
Definition: afsk.hh:61
sdr::AFSK::_sampleRate
float _sampleRate
The sample rate of the input signal.
Definition: afsk.hh:53
sdr::AFSK::AFSK
AFSK(double baud=1200.0, double Fmark=1200.0, double Fspace=2200.0, Mode mode=TRANSITION)
Constructs a AFSK node with the specified baud rate and Fmark, Fspace frequencies.
Definition: afsk.cc:9
sdr::AFSK::NORMAL
Normal mode (i.e. mark -> 1, space -> 0).
Definition: afsk.hh:18
sdr::AFSK::_symbols
Buffer< int16_t > _symbols
Ring buffer of the last _corrLen symbols.
Definition: afsk.hh:88
sdr::AFSK::_markHist
Buffer< std::complex< float > > _markHist
FIR filter buffer.
Definition: afsk.hh:74
sdr::AFSK::_corrLen
uint32_t _corrLen
Correlation length, the number of "symbols" per bit.
Definition: afsk.hh:65
sdr::AFSK::Mode
Mode
Possible bit decoding modes.
Definition: afsk.hh:17
sdr::AFSK::_dl_idx
size_t _dl_idx
Delay line index.
Definition: afsk.hh:85
sdr::AFSK::_baud
float _baud
The baud rate.
Definition: afsk.hh:57
sdr::AFSK::_lastBits
uint32_t _lastBits
Last received bits.
Definition: afsk.hh:97
sdr::AFSK::_mode
Mode _mode
Bit encoding mode.
Definition: afsk.hh:63
sdr::AFSK::_spaceHist
Buffer< std::complex< float > > _spaceHist
FIR filter buffer.
Definition: afsk.hh:76
sdr::AFSK::_getSymbol
double _getSymbol()
Performs the convolution filtering of the mark & space frequencies.
Definition: afsk.hh:37
sdr::AFSK::process
virtual void process(const Buffer< int16_t > &buffer, bool allow_overwrite)
Processes the given buffer.
Definition: afsk.cc:104
sdr::AFSK::_gainOmega
float _gainOmega
PLL gain.
Definition: afsk.hh:107
sdr::AFSK::_symSum
int32_t _symSum
Sum of the current _corrLen symbols.
Definition: afsk.hh:92
sdr::Buffer< int16_t >
sdr::AFSK::_omegaMax
float _omegaMax
Minimum PLL phase speed.
Definition: afsk.hh:105
sdr::AFSK::config
virtual void config(const Config &src_cfg)
Configures the node.
Definition: afsk.cc:20
sdr::AFSK::_muIncr
float _muIncr
Symbol subsampling.
Definition: afsk.hh:81