Detect signaling tones before trying to detect MF tones.
This prevents missing signaling tones, if MF tones or noise is present.
This commit is contained in:
parent
2c02ad31c0
commit
480179541f
|
@ -35,6 +35,7 @@
|
|||
//#define DEBUG_DEMODULATOR
|
||||
|
||||
#define NUM_TONES 8
|
||||
#define NUM_MF_TONES 6
|
||||
#define db2level(db) pow(10, (double)(db) / 20.0)
|
||||
#define level2db(level) (20 * log10(level))
|
||||
|
||||
|
@ -416,19 +417,19 @@ static void detect_tones(dsp_t *dsp, sample_t *samples, sample_t **levels_square
|
|||
}
|
||||
#endif
|
||||
|
||||
/* find the tone which is the loudest */
|
||||
/* find the signaling tone which is the loudest */
|
||||
f1 = -1;
|
||||
f1_level_squared = -1.0;
|
||||
for (t = 0; t < dsp->mf_demod->tones; t++) {
|
||||
for (t = NUM_MF_TONES; t < dsp->mf_demod->tones; t++) {
|
||||
if (levels_squared[t][s] > f1_level_squared) {
|
||||
f1_level_squared = levels_squared[t][s];
|
||||
f1 = t;
|
||||
}
|
||||
}
|
||||
/* find the tone which is the second loudest */
|
||||
/* find the signaling tone which is the second loudest */
|
||||
f2 = -1;
|
||||
f2_level_squared = -1.0;
|
||||
for (t = 0; t < dsp->mf_demod->tones; t++) {
|
||||
for (t = NUM_MF_TONES; t < dsp->mf_demod->tones; t++) {
|
||||
if (t == f1)
|
||||
continue;
|
||||
if (levels_squared[t][s] > f2_level_squared) {
|
||||
|
@ -442,6 +443,35 @@ static void detect_tones(dsp_t *dsp, sample_t *samples, sample_t **levels_square
|
|||
if (f2 >= 0 && f2_level_squared < tone_min_ampl_sq[f2])
|
||||
f2 = -1;
|
||||
|
||||
/* if no signaling tone was found, check MF tones */
|
||||
if (f1 < 0) {
|
||||
/* find the MF tone which is the loudest */
|
||||
f1 = -1;
|
||||
f1_level_squared = -1.0;
|
||||
for (t = 0; t < NUM_MF_TONES; t++) {
|
||||
if (levels_squared[t][s] > f1_level_squared) {
|
||||
f1_level_squared = levels_squared[t][s];
|
||||
f1 = t;
|
||||
}
|
||||
}
|
||||
/* find the MF tone which is the second loudest */
|
||||
f2 = -1;
|
||||
f2_level_squared = -1.0;
|
||||
for (t = 0; t < NUM_MF_TONES; t++) {
|
||||
if (t == f1)
|
||||
continue;
|
||||
if (levels_squared[t][s] > f2_level_squared) {
|
||||
f2_level_squared = levels_squared[t][s];
|
||||
f2 = t;
|
||||
}
|
||||
}
|
||||
/* now check if the minimum level is reached */
|
||||
if (f1 >= 0 && f1_level_squared < tone_min_ampl_sq[f1])
|
||||
f1 = -1;
|
||||
if (f2 >= 0 && f2_level_squared < tone_min_ampl_sq[f2])
|
||||
f2 = -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DEMODULATOR
|
||||
if (incoming)
|
||||
printf("%s f1=%.0f (%.1f dBm) f2=%.0f (%.1f dBm)\n", CHAN, (f1 >= 0) ? tone_freq[f1] : 0, level2db(sqrt(f1_level_squared)), (f2 >= 0) ? tone_freq[f2] : 0, level2db(sqrt(f2_level_squared)));
|
||||
|
|
Loading…
Reference in New Issue