54 if (n == 0)
return false;
76 return bin + (bin & 1);
95 LOGE(
"OFDM: carriers must be between 4 and 128, not %d",
carriers);
99 LOGE(
"OFDM: invalid carrier_spacing, first_freq or guard");
103 LOGE(
"OFDM: the highest carrier %.1f Hz must be below %.1f Hz",
105 (
double)(sample_rate / 2.0f));
109 LOGE(
"OFDM: invalid max_frame: %d",
max_frame);
121 uint32_t x = (uint32_t)(carrier + 1) * 2654435761u + symbol * 40503u;
130 if (mode ==
nullptr)
return 0;
131 const char* prefix =
"ofdm";
132 for (
int j = 0; j < 4; j++)
133 if (tolower(mode[j]) != prefix[j])
return 0;
134 int n = atoi(mode + 4);
135 return (n == 16 || n == 32 || n == 64) ? n : 0;
146 for (
int i = 0; i <
size; i++) {
147 double angle = 2.0 * M_PI * i /
size;
Sine and cosine of 2 * PI * i / size.
Definition OFDM.h:140
int size
Definition OFDM.h:156
audio_tools::Vector< float > cos_table
Definition OFDM.h:157
void begin(int size)
Definition OFDM.h:142
float cosine(int i) const
Definition OFDM.h:152
audio_tools::Vector< float > sin_table
Definition OFDM.h:158
float sine(int i) const
Definition OFDM.h:153
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11
float symbolRate() const
OFDM symbols per second.
Definition OFDM.h:85
float first_freq
frequency of the first carrier in Hz
Definition OFDM.h:35
float carrier_spacing
distance of the carriers in Hz
Definition OFDM.h:33
float rx_noise
receiver: (testing only) amplitude of added uniform noise
Definition OFDM.h:49
static bool isMode(const char *mode)
true if the mode is an OFDM mode
Definition OFDM.h:62
int firstBin() const
DFT bin of the first carrier: even, for the sync symbol.
Definition OFDM.h:74
static int knownPhase(int symbol, int carrier)
Definition OFDM.h:120
float volume
transmit amplitude (0.0 - 1.0)
Definition OFDM.h:39
OFDMConfig()
Definition OFDM.h:24
uint8_t channel
receiver: input channel which is used for the decoding
Definition OFDM.h:47
int prefixSize() const
length of the cyclic prefix in samples
Definition OFDM.h:71
int carriers
number of carriers (4 - 128)
Definition OFDM.h:31
bool isValid() const
Checks the configuration: returns false (and logs the reason) if invalid.
Definition OFDM.h:93
float bitRate() const
data bits per second
Definition OFDM.h:90
int fftSize() const
length of the useful part of a symbol (DFT size) in samples
Definition OFDM.h:65
static int headerSymbols(int carriers)
Number of symbols of the header (32 bits, one bit per carrier).
Definition OFDM.h:116
bool rx_one
receiver: stop after the first frame
Definition OFDM.h:45
float guard
length of the cyclic prefix relative to the symbol (0.0 - 0.5)
Definition OFDM.h:37
float sync_threshold
receiver: minimum normalized correlation of the sync symbol
Definition OFDM.h:43
bool setMode(const char *mode)
Selects "ofdm16", "ofdm32" or "ofdm64": returns false if invalid.
Definition OFDM.h:52
float carrierFrequency(int idx) const
frequency of the carrier with the indicated index
Definition OFDM.h:80
int max_frame
transmitter: max number of bytes per frame
Definition OFDM.h:41
static int modeCarriers(const char *mode)
Definition OFDM.h:129