57 static bool isMode(
const char* mode) {
58 if (mode ==
nullptr)
return false;
59 const char* name =
"dtmf";
60 for (
int j = 0; j < 5; j++)
61 if (tolower(mode[j]) != name[j])
return false;
69 LOGE(
"DTMF: invalid durations");
72 if (sample_rate < 4000) {
73 LOGE(
"DTMF: the sample rate must be at least 4000 Hz");
87 static const float*
rows() {
88 static const float freqs[4] = {697.0f, 770.0f, 852.0f, 941.0f};
94 static const float freqs[4] = {1209.0f, 1336.0f, 1477.0f, 1633.0f};
99 static char key(
int row,
int column) {
return keys()[row * 4 + column]; }
103 static bool find(
char ch,
int& row,
int& column) {
104 ch = toupper((
unsigned char)ch);
105 const char* pos = ch == 0 ? nullptr : strchr(
keys(), ch);
106 if (pos ==
nullptr)
return false;
107 int idx = pos -
keys();
114 static const char*
keys() {
return "123A456B789C*0#D"; }
The DTMF keypad: the tones and the characters of the 16 keys.
Definition DTMF.h:84
static const char * keys()
Definition DTMF.h:114
static const float * rows()
row frequencies in Hz
Definition DTMF.h:87
static char key(int row, int column)
Character of the key in the indicated row and column.
Definition DTMF.h:99
static const float * columns()
column frequencies in Hz
Definition DTMF.h:93
static bool find(char ch, int &row, int &column)
Definition DTMF.h:103
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11
float max_twist_db
Definition DTMF.h:39
int comma_ms
transmitter: duration of the pause for a ',' in ms
Definition DTMF.h:32
int rx_timeout_ms
receiver: the end of a transmission is reported after this silence
Definition DTMF.h:44
static bool isMode(const char *mode)
true if the mode name is "dtmf"
Definition DTMF.h:57
bool isValid() const
Checks the configuration: returns false (and logs the reason) if invalid.
Definition DTMF.h:66
float min_amplitude
receiver: minimum amplitude of each tone (1.0 = full scale)
Definition DTMF.h:36
uint8_t channel
receiver: input channel which is used for the decoding
Definition DTMF.h:48
bool rx_one
receiver: stop after the first transmission
Definition DTMF.h:46
float volume
transmit amplitude (0.0 - 1.0) of the sum of both tones
Definition DTMF.h:34
int pause_ms
transmitter: duration of the pause after a tone in ms
Definition DTMF.h:30
bool setMode(const char *mode)
Definition DTMF.h:54
int tone_ms
transmitter: duration of a tone in ms
Definition DTMF.h:28
float rx_noise
receiver: (testing only) amplitude of added uniform noise
Definition DTMF.h:50
float group_ratio_db
Definition DTMF.h:42
DTMFConfig()
Definition DTMF.h:21