aboutsummaryrefslogtreecommitdiffstats
path: root/src/nmt
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2016-05-01 10:23:45 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2016-05-06 07:05:40 +0200
commitb73894ac49e85217322adc73bca53a7c991dc183 (patch)
treeb6e0e18a423885bc856551a15fd3f7c08d18b92b /src/nmt
parent47dbf094d9fb3d4cc73248378826ba36f16698f3 (diff)
B-Netz / NMT: minor changes at signal detection
Diffstat (limited to 'src/nmt')
-rw-r--r--src/nmt/dsp.c16
-rw-r--r--src/nmt/nmt.c4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/nmt/dsp.c b/src/nmt/dsp.c
index 9d3a207..438f408 100644
--- a/src/nmt/dsp.c
+++ b/src/nmt/dsp.c
@@ -303,41 +303,45 @@ static inline void fsk_decode_step(nmt_t *nmt, int pos)
nmt->rx_sample_count += nmt->fsk_filter_step;
level = audio_level(spl, max);
+ /* limit level to prevent division by zero */
+ if (level < 0.01)
+ level = 0.01;
// level = 0.63662 / 2.0;
audio_goertzel(spl, max, pos, nmt->fsk_coeff, result, 2);
/* calculate soft bit from both frequencies */
softbit = (result[1] / level - result[0] / level + 1.0) / 2.0;
+//printf("%.3f: %.3f\n", level, softbit);
/* scale it, since both filters overlap by some percent */
#define MIN_QUALITY 0.33
softbit = (softbit - MIN_QUALITY) / (1.0 - MIN_QUALITY - MIN_QUALITY);
- if (softbit > 1)
- softbit = 1;
- if (softbit < 0)
- softbit = 0;
#ifdef DEBUG_FILTER
// printf("|%s", show_level(result[0]/level*100));
// printf("|%s| low=%.3f high=%.3f level=%d\n", show_level(result[1]/level*100), result[0]/level, result[1]/level, (int)level);
printf("|%s| softbit=%.3f\n", show_level(softbit * 100), softbit);
#endif
+ if (softbit > 1)
+ softbit = 1;
+ if (softbit < 0)
+ softbit = 0;
if (softbit > 0.5)
bit = 1;
else
bit = 0;
if (nmt->fsk_filter_bit != bit) {
+ /* if we have a bit change, reset sample counter to one half bit duration */
#ifdef DEBUG_FILTER
puts("bit change");
#endif
- /* if we have a bit change, reset sample counter to one half bit duration */
nmt->fsk_filter_bit = bit;
nmt->fsk_filter_sample = 5;
} else if (--nmt->fsk_filter_sample == 0) {
+ /* if sample counter bit reaches 0, we reset sample counter to one bit duration */
#ifdef DEBUG_FILTER
puts("sample");
#endif
- /* if sample counter bit reaches 0, we reset sample counter to one bit duration */
// quality = result[bit] / level;
if (softbit > 0.5)
quality = softbit * 2.0 - 1.0;
diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c
index b8278bc..4249f48 100644
--- a/src/nmt/nmt.c
+++ b/src/nmt/nmt.c
@@ -1124,9 +1124,10 @@ void nmt_receive_frame(nmt_t *nmt, const char *bits, double quality, double leve
frame_t frame;
int rc;
+ PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0 + 0.5, quality * 100.0 + 0.5);
+
rc = decode_frame(&frame, bits, (nmt->sender.loopback) ? MTX_TO_XX : XX_TO_MTX, (nmt->state == STATE_MT_PAGING));
if (rc < 0) {
- PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0, quality * 100.0);
PDEBUG(DNMT, (nmt->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received invalid frame.\n");
return;
}
@@ -1134,7 +1135,6 @@ void nmt_receive_frame(nmt_t *nmt, const char *bits, double quality, double leve
/* frame counter */
nmt->rx_frame_count += (int)(frames_elapsed + 0.5);
- PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0, quality * 100.0);
PDEBUG(DNMT, (nmt->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received frame %s\n", nmt_frame_name(frame.index));
if (nmt->sender.loopback)