From ef13343925db655cea7284c7f33df1da9e0187d1 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Tue, 19 Mar 2024 12:46:27 -0400 Subject: [PATCH] RTL_FM Input for Analog/M17 Encoder; --- src/m17.c | 4 ++-- src/rtl_sdr_fm.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/m17.c b/src/m17.c index b709b44..cb3f102 100644 --- a/src/m17.c +++ b/src/m17.c @@ -1855,8 +1855,8 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state) //run lpf and hpf // lpf8 (state, voice1, 160); // lpf8 (state, voice2, 160); - hpf8 (state, voice1, 160); - hpf8 (state, voice2, 160); + // hpf (state, voice1, 160); + // hpf (state, voice2, 160); //convert out audio input into CODEC2 (3200bps) 8 byte data stream uint8_t vc1_bytes[8]; memset (vc1_bytes, 0, sizeof(vc1_bytes)); diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp index e571503..2762d47 100644 --- a/src/rtl_sdr_fm.cpp +++ b/src/rtl_sdr_fm.cpp @@ -815,6 +815,34 @@ void dongle_init(struct dongle_state *s) s->demod_target = &demod; } +void demod_init_analog(struct demod_state *s) +{ + s->rate_in = rtl_bandwidth; + s->rate_out = rtl_bandwidth; + s->squelch_level = 0; + s->conseq_squelch = 10; + s->terminate_on_squelch = 0; + s->squelch_hits = 11; + s->downsample_passes = 1; // + s->comp_fir_size = 0; + s->prev_index = 0; + s->post_downsample = 1; //1 -- once this works, default = 4 -- doesn't work on the official rtl-sdr source code either + s->custom_atan = 0; + s->deemph = 1; // + s->rate_out2 = rtl_bandwidth; // -1 flag for disabled -- this enables low_pass_real, seems to work okay + s->mode_demod = &fm_demod; + s->pre_j = s->pre_r = s->now_r = s->now_j = 0; + s->prev_lpr_index = 0; + s->deemph_a = 0; // + s->now_lpr = 0; + s->dc_block = 1; // + s->dc_avg = 0; + pthread_rwlock_init(&s->rw, NULL); + pthread_cond_init(&s->ready, NULL); + pthread_mutex_init(&s->ready_m, NULL); + s->output_target = &output; +} + void demod_init_ro2(struct demod_state *s) { s->rate_in = rtl_bandwidth; @@ -1005,6 +1033,8 @@ void open_rtlsdr_stream(dsd_opts *opts) //init with low pass if decoding P25 or EDACS/Provoice if (opts->frame_p25p1 == 1 || opts->frame_p25p2 == 1 || opts->frame_provoice == 1) demod_init_ro2(&demod); + else if (opts->analog_only == 1 || opts->m17encoder == 1) + demod_init_analog(&demod); else demod_init(&demod); output_init(&output); controller_init(&controller);