2015-11-16 23:49:54 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "liquid/liquid.h"
|
|
|
|
#include "IOThread.h"
|
|
|
|
#include "AudioThread.h"
|
2015-11-20 19:32:53 -05:00
|
|
|
#include <cmath>
|
2015-11-23 20:44:48 -05:00
|
|
|
#include <atomic>
|
2015-11-16 23:49:54 -05:00
|
|
|
|
|
|
|
class ModemKit {
|
|
|
|
public:
|
|
|
|
ModemKit() : sampleRate(0), audioSampleRate(0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
long long sampleRate;
|
|
|
|
int audioSampleRate;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ModemIQData: public ReferenceCounter {
|
|
|
|
public:
|
|
|
|
std::vector<liquid_float_complex> data;
|
|
|
|
long long sampleRate;
|
|
|
|
|
|
|
|
ModemIQData() : sampleRate(0) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
~ModemIQData() {
|
|
|
|
std::lock_guard < std::mutex > lock(m_mutex);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-23 18:41:10 -05:00
|
|
|
// Copy of SoapySDR::Range, original comments
|
|
|
|
class ModemRange
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! Create an empty range (0.0, 0.0)
|
|
|
|
ModemRange(void);
|
|
|
|
|
|
|
|
//! Create a min/max range
|
|
|
|
ModemRange(const double minimum, const double maximum);
|
|
|
|
|
|
|
|
//! Get the range minimum
|
|
|
|
double minimum(void) const;
|
|
|
|
|
|
|
|
//! Get the range maximum
|
|
|
|
double maximum(void) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
double _min, _max;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Modified version of SoapySDR::ArgInfo, original comments
|
|
|
|
class ModemArgInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//! Default constructor
|
|
|
|
ModemArgInfo(void);
|
|
|
|
|
|
|
|
//! The key used to identify the argument (required)
|
|
|
|
std::string key;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The default value of the argument when not specified (required)
|
|
|
|
* Numbers should use standard floating point and integer formats.
|
|
|
|
* Boolean values should be represented as "true" and "false".
|
|
|
|
*/
|
|
|
|
std::string value;
|
|
|
|
|
|
|
|
//! The displayable name of the argument (optional, use key if empty)
|
|
|
|
std::string name;
|
|
|
|
|
|
|
|
//! A brief description about the argument (optional)
|
|
|
|
std::string description;
|
|
|
|
|
|
|
|
//! The units of the argument: dB, Hz, etc (optional)
|
|
|
|
std::string units;
|
|
|
|
|
|
|
|
//! The data type of the argument (required)
|
|
|
|
enum Type { BOOL, INT, FLOAT, STRING, PATH_DIR, PATH_FILE, COLOR } type;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* The range of possible numeric values (optional)
|
|
|
|
* When specified, the argument should be restricted to this range.
|
|
|
|
* The range is only applicable to numeric argument types.
|
|
|
|
*/
|
|
|
|
ModemRange range;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* A discrete list of possible values (optional)
|
|
|
|
* When specified, the argument should be restricted to this options set.
|
|
|
|
*/
|
|
|
|
std::vector<std::string> options;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* A discrete list of displayable names for the enumerated options (optional)
|
|
|
|
* When not specified, the option value itself can be used as a display name.
|
|
|
|
*/
|
|
|
|
std::vector<std::string> optionNames;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ModemArgInfo> ModemArgInfoList;
|
|
|
|
|
2015-11-16 23:49:54 -05:00
|
|
|
class Modem;
|
2015-11-17 00:21:17 -05:00
|
|
|
typedef std::map<std::string,Modem *> ModemFactoryList;
|
2015-11-16 23:49:54 -05:00
|
|
|
|
2015-11-26 01:54:54 -05:00
|
|
|
typedef std::map<std::string, std::string> ModemSettings;
|
|
|
|
|
2015-11-16 23:49:54 -05:00
|
|
|
class Modem {
|
|
|
|
public:
|
2015-11-18 23:40:30 -05:00
|
|
|
static void addModemFactory(Modem *factorySingle);
|
2015-11-16 23:49:54 -05:00
|
|
|
static ModemFactoryList getFactories();
|
2015-11-23 20:44:48 -05:00
|
|
|
|
2015-11-29 13:35:12 -05:00
|
|
|
static Modem *makeModem(std::string modemName);
|
2015-11-23 20:44:48 -05:00
|
|
|
|
2015-11-18 23:40:30 -05:00
|
|
|
virtual std::string getType() = 0;
|
|
|
|
virtual std::string getName() = 0;
|
2015-11-23 20:44:48 -05:00
|
|
|
|
2015-11-17 20:20:12 -05:00
|
|
|
virtual Modem *factory() = 0;
|
2015-11-16 23:49:54 -05:00
|
|
|
|
2015-11-17 21:22:51 -05:00
|
|
|
Modem();
|
|
|
|
virtual ~Modem();
|
|
|
|
|
2015-11-23 18:41:10 -05:00
|
|
|
virtual ModemArgInfoList getSettings();
|
|
|
|
virtual void writeSetting(std::string setting, std::string value);
|
2015-11-26 01:54:54 -05:00
|
|
|
virtual void writeSettings(ModemSettings settings);
|
2015-11-23 18:41:10 -05:00
|
|
|
virtual std::string readSetting(std::string setting);
|
2015-11-26 01:54:54 -05:00
|
|
|
virtual ModemSettings readSettings();
|
2015-11-23 20:03:47 -05:00
|
|
|
|
2015-11-22 19:56:25 -05:00
|
|
|
virtual int checkSampleRate(long long sampleRate, int audioSampleRate) = 0;
|
2015-11-23 20:03:47 -05:00
|
|
|
|
2015-11-17 20:20:12 -05:00
|
|
|
virtual ModemKit *buildKit(long long sampleRate, int audioSampleRate) = 0;
|
|
|
|
virtual void disposeKit(ModemKit *kit) = 0;
|
2015-11-23 20:03:47 -05:00
|
|
|
|
2015-11-17 20:20:12 -05:00
|
|
|
virtual void demodulate(ModemKit *kit, ModemIQData *input, AudioThreadInput *audioOut) = 0;
|
2015-11-23 20:44:48 -05:00
|
|
|
|
|
|
|
bool shouldRebuildKit();
|
|
|
|
void rebuildKit();
|
|
|
|
void clearRebuildKit();
|
|
|
|
|
2015-11-16 23:49:54 -05:00
|
|
|
private:
|
|
|
|
static ModemFactoryList modemFactories;
|
2015-11-23 20:44:48 -05:00
|
|
|
std::atomic_bool refreshKit;
|
2015-11-20 19:32:53 -05:00
|
|
|
};
|