From 5a9c9c7401cf1c21d2ba1654576bd4024b22dbb5 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 13 May 2016 08:44:42 +0200 Subject: [PATCH] C-Netz: Send 5280 Hz test tone on idle speech channel --- src/cnetz/dsp.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/cnetz/dsp.c b/src/cnetz/dsp.c index 75550a0..9ea87da 100644 --- a/src/cnetz/dsp.c +++ b/src/cnetz/dsp.c @@ -216,6 +216,39 @@ void calc_clock_speed(cnetz_t *cnetz, uint64_t samples, int tx, int result) PDEBUG(DDSP, DEBUG_NOTICE, "Clock: RX=%.2f TX=%.2f; Signal: RX=%.2f TX=%.2f ppm\n", speed_ppm_rx[0], speed_ppm_tx[0], speed_ppm_rx[1], speed_ppm_tx[1]); } +static int fsk_testtone_encode(cnetz_t *cnetz) +{ + int16_t *spl; + double phase, bitstep; + int i, count; + + spl = cnetz->fsk_tx_buffer; + phase = cnetz->fsk_tx_phase; + bitstep = cnetz->fsk_tx_bitstep * 256.0; + + /* add 198 bits of noise */ + for (i = 0; i < 99; i++) { + do { + *spl++ = ramp_up[(int)phase]; + phase += bitstep; + } while (phase < 256.0); + phase -= 256.0; + do { + *spl++ = ramp_down[(int)phase]; + phase += bitstep; + } while (phase < 256.0); + phase -= 256.0; + } + + /* depending on the number of samples, return the number */ + count = ((uintptr_t)spl - (uintptr_t)cnetz->fsk_tx_buffer) / sizeof(*spl); + + cnetz->fsk_tx_phase = phase; + cnetz->fsk_tx_buffer_length = count; + + return count; +} + static int fsk_nothing_encode(cnetz_t *cnetz) { int16_t *spl; @@ -652,7 +685,7 @@ again: break; case DSP_MODE_OFF: default: - fsk_nothing_encode(cnetz); + fsk_testtone_encode(cnetz); } if (cnetz->dsp_mode == DSP_MODE_SPK_V) {