54 if (mode ==
nullptr)
return false;
55 if (!
isMode(mode))
return false;
56 int n = atoi(mode + 4);
83 static bool isMode(
const char* mode) {
84 if (mode ==
nullptr)
return false;
85 const char* prefix =
"mfsk";
86 for (
int j = 0; j < 4; j++)
87 if (tolower(mode[j]) != prefix[j])
return false;
94 while ((1 << bits) <
tones) bits++;
107 return n < 2 ? 2 : n;
112 static const int pattern[4] = {2, 4, 4, 2};
113 return tones / pattern[idx % 4];
125 LOGE(
"MFSK: tones must be 4, 8, 16, 32 or 64, not %d",
tones);
129 LOGE(
"MFSK: invalid symbol_rate, base_freq or tone_spacing");
133 LOGE(
"MFSK: highest tone %.1f Hz must be below %.1f Hz",
138 LOGE(
"MFSK: at least 8 samples per symbol are needed");
142 LOGE(
"MFSK: at least 4 preamble symbols are needed");
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11
uint8_t channel
receiver: input channel which is used for the decoding
Definition MFSKConfig.h:47
float spacing() const
distance between the tones in Hz
Definition MFSKConfig.h:99
float toneFrequency(int idx) const
frequency of the tone with the indicated index
Definition MFSKConfig.h:102
MFSKConfig()
Definition MFSKConfig.h:24
float rx_noise
receiver: (testing only) amplitude of added uniform noise
Definition MFSKConfig.h:49
float bitRate() const
data bits per second
Definition MFSKConfig.h:117
float base_freq
frequency of the lowest tone in Hz
Definition MFSKConfig.h:35
float volume
transmit amplitude (0.0 - 1.0)
Definition MFSKConfig.h:39
float samplesPerSymbol() const
number of samples per symbol
Definition MFSKConfig.h:120
float symbol_rate
symbols per second
Definition MFSKConfig.h:33
int tones
number of tones: 4, 8, 16, 32 or 64
Definition MFSKConfig.h:31
bool setMode(const char *mode)
Definition MFSKConfig.h:53
int bitsPerSymbol() const
bits per symbol: log2(tones)
Definition MFSKConfig.h:92
float tone_spacing
distance between the tones in Hz (0 = symbol_rate)
Definition MFSKConfig.h:37
int preamble_symbols
number of preamble symbols (alternating lowest and highest tone)
Definition MFSKConfig.h:41
bool isValid() const
Checks the configuration: returns false (and logs the reason) if invalid.
Definition MFSKConfig.h:123
int syncSymbol(int idx) const
tone of the sync symbol with the indicated index
Definition MFSKConfig.h:111
float min_amplitude
receiver: minimum amplitude of a tone (1.0 = full scale)
Definition MFSKConfig.h:43
bool rx_one
receiver: stop after the first carrier was lost
Definition MFSKConfig.h:45
int syncLength() const
number of sync symbols after the preamble: they carry at least 8 bits
Definition MFSKConfig.h:105
static bool isMode(const char *mode)
true if the mode name is a MFSK mode
Definition MFSKConfig.h:83