aboutsummaryrefslogtreecommitdiffstats
path: root/src/nmt
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-01-29 07:27:08 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-02-18 21:01:15 +0100
commitf72c53757d4ce30c37ecefda825f21f42c60b05e (patch)
tree4f5ebcf7494e1a12a90e325781ab857e86677f7a /src/nmt
parent7e45f556cec493c3c77fcb6400d8ae211faf2220 (diff)
B-Netz, NMT: Improved check for minimum required sample rate
Diffstat (limited to 'src/nmt')
-rw-r--r--src/nmt/dsp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nmt/dsp.c b/src/nmt/dsp.c
index 3d7dd52..65dc8ae 100644
--- a/src/nmt/dsp.c
+++ b/src/nmt/dsp.c
@@ -120,8 +120,8 @@ int dsp_init_sender(nmt_t *nmt)
/* attack (3ms) and recovery time (13.5ms) according to NMT specs */
init_compandor(&nmt->cstate, 8000, 3.0, 13.5, COMPANDOR_0DB);
- /* this should not happen. it is implied by previous check */
- if (nmt->supervisory && nmt->sender.samplerate < 12000) {
+ /* a symbol rate of 1200 Hz, times check interval of FILTER_STEPS */
+ if (nmt->sender.samplerate < (double)BIT_RATE / (double)FILTER_STEPS) {
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 12000 Hz to process FSK+supervisory signal.\n");
return -EINVAL;
}
@@ -313,7 +313,7 @@ static inline void fsk_decode_step(nmt_t *nmt, int pos)
spl = nmt->fsk_filter_spl;
/* count time in bits */
- nmt->rx_bits_count += 0.1;
+ nmt->rx_bits_count += FILTER_STEPS;
level = audio_level(spl, max);
/* limit level to prevent division by zero */
@@ -462,8 +462,8 @@ void sender_receive(sender_t *sender, sample_t *samples, int length)
}
/* if 1/10th of a bit duration is reached, decode buffer */
step += bps;
- if (step >= 0.1) {
- step -= 0.1;
+ if (step >= FILTER_STEPS) {
+ step -= FILTER_STEPS;
fsk_decode_step(nmt, pos);
}
}