58 Commits

Author SHA1 Message Date
lwvmobile
1bf60caa6f Merge pull request #313 from arancormonk/perf/rtl-sdr-fm-resampler-simd-rotate90
rtl_sdr_fm: fix FLL feedback and rotate_90 tail; aligned/SIMD resampler; safer defaults and logs
2025-09-08 01:27:29 -04:00
arancormonk
dc055c6585 rtl_sdr_fm: fix implementation of FLL, actually feedback error...other minor bug fixes and optimizations 2025-09-07 22:17:49 -04:00
arancormonk
eb02148491 rtl_sdr_fm: optimize resampler/DSP (aligned buffers, restrict/assumed alignment, optional SSE2/NEON); fix rotate_90 tail; add errno to RT logs; correct downsample_passes calc. 2025-09-07 21:00:27 -04:00
lwvmobile
6cdcac5db2 Merge pull request #312 from arancormonk/rtl_overhaul_cygwin_fix_1
Fix CPU affinity on Cygwin builds
2025-09-07 10:24:15 -04:00
arancormonk
a2a70bbb15 Fix Cygwin build 2025-09-07 10:13:03 -04:00
lwvmobile
e2a6e351c5 Merge pull request #311 from arancormonk/rtl_overhaul_arm_fix_2
Silence unused variable warning on ARM 32bit compilation
2025-09-05 20:57:19 -04:00
arancormonk
4dfe095a7c Silence unused variable warning on ARM 32bit compilation 2025-09-05 20:50:11 -04:00
lwvmobile
fede9b4e20 Merge pull request #310 from arancormonk/rtl_overhaul_arm_fix_1
RTL-SDR overhaul: Fix NEON widening code, move x86 vars into x86 block to silence compile warnings on ARM
2025-09-05 20:01:47 -04:00
arancormonk
493800a0f3 Fix NEON widening code to avoid using vsubl_u8 (which returns uint16x8_t) and instead zero-extend with vmovl_u8, reinterpret to int16x8_t, then subtract 127 with vsubq_s16. This should fix the type mismatch and produce correct signed results. Moved use_avx2, use_sse2, and use_ssse3 declarations inside the #if defined(__x86_64__) || defined(__i386__) block. 2025-09-05 19:21:57 -04:00
lwvmobile
c0b6f186bd Merge pull request #308 from arancormonk/perf/rtlsdr-demod-optimizations
RTL‑SDR demod overhaul: runtime SIMD, lock‑free ring, L/M resampler, power‑domain squelch, and DSP/perf fixes
2025-09-05 15:51:54 -04:00
arancormonk
8b423a2f42 rtl_sdr_fm: fix potential race condition, zero int all demod init funcs, add timeouts to prevent indefinite blocking, remove producer-side tail advancement, harden udp socket read loop 2025-09-04 19:11:25 -04:00
arancormonk
8ec385fdf2 ensure all old references of rms have been updated to pwr, we avoid sqrt calculations and squelch comparisons are using the same units with updated default level 2025-09-04 14:08:22 -04:00
arancormonk
da8b9b6116 rtl_sdr_fm: add additional bounds checks and cleanup extra line 2025-09-04 12:53:54 -04:00
arancormonk
a866d98e75 rtl_sdr_fm: comment cleanup 2025-09-04 12:38:41 -04:00
arancormonk
e094f95b03 rtl_sdr_fm: FLL rotator - improve sine/cos approximation 2025-09-04 10:20:39 -04:00
arancormonk
f052271a16 rtl_sdr_fm: fix mean_power - integer-only implementation 2025-09-04 10:13:05 -04:00
arancormonk
09bf040810 rtl_sdr_fm: fix low_pass_simple - normalize to avoid amplitude growth/clipping 2025-09-04 10:06:11 -04:00
arancormonk
48b032e47a rtl_sdr_fm: fix Gardner timing interpolation cost and gating 2025-09-04 10:01:17 -04:00
arancormonk
046846337a rtl_sdr_fm: fix half-band decimator - exploit symmetry/zeros and consider SIMD 2025-09-04 09:57:50 -04:00
arancormonk
836da1f556 rtl_sdr_fm: fix USB callback - avoid extra copy when enqueuing into input ring. 2025-09-04 09:48:17 -04:00
arancormonk
dd8620bc39 rtl_sdr_fm: remove per-sample memmove from resampler, use ring buffer. 2025-09-04 09:34:09 -04:00
arancormonk
283d000b59 rtl_sdr_fm: fix critical correctness bug: +1 DC bias in rotate+widen paths 2025-09-04 09:27:59 -04:00
arancormonk
5834127ff7 rtl_sdr_fm: fix rotate+widen tail handling (scalar/AVX2/NEON) to preserve 90° rotation and add SSSE3 rotate+widen with runtime dispatch on x86. Also include tmmintrin and clarify SSE2 fallback comment. 2025-09-03 23:33:32 -04:00
arancormonk
2ce089ccf8 rtl_sdr_fm: make SIMD runtime dispatch thread-safe with pthread_once and ensure AVX2/SSE2 paths compile by relying on function-level target attributes (remove AVX2/SSE2 guards). Gate NEON rotate to AArch64 (ARMv7 falls back to scalar) while retaining NEON widen for portability and performance. 2025-09-03 23:21:37 -04:00
arancormonk
4e64ef1c11 rtl_sdr_fm: add runtime SIMD dispatch for widen/rotate paths, selecting AVX2/SSE2/NEON via CPUID/XGETBV (x86) or getauxval (ARM) with scalar fallbacks. Replace compile-time guards with lazy-initialized function-pointer wrappers so binaries run optimally across CPUs without changing call sites. 2025-09-03 23:06:55 -04:00
arancormonk
c764cf0eda rtl_sdr_fm: replace USB→demod double-buffer/condvar handoff with a lock-free SPSC ring; enqueue widened blocks and drop oldest on overflow to keep the callback non-blocking. Demod now reads ring blocks; ring is initialized/cleaned up, reducing wakeups and latency. 2025-09-03 22:45:18 -04:00
arancormonk
8b4fa81711 rtl_sdr_fm: consume HB cascade output in-place to avoid the final memcpy. Track the current buffer and assign lowpassed to the last stage’s output, preserving correctness while reducing memory traffic. 2025-09-03 22:38:50 -04:00
arancormonk
106aae1814 rtl_sdr_fm: fuse interleaved complex half-band decimation to avoid deinterleave/reinterleave in full_demod, reducing memory traffic and copies. Maintain per‑stage histories and equivalent output while improving throughput. 2025-09-03 22:35:34 -04:00
arancormonk
391048a45a rtl_sdr_fm: vectorize rotate+widen path: add AVX2/NEON implementations for widen_rotate90_u8_to_s16_bias127 with scalar tail fallback. This applies the 90° rotation and bias-127 widening in vectors to reduce callback CPU without changing behavior. 2025-09-03 22:23:05 -04:00
arancormonk
1b9c3aa659 rtl_sdr_fm: add residual-CFO FLL and optional Gardner timing correction before discriminator (TED disabled by default and applied only to non-FM unless forced), with linear interpolation, nominal 1/sps advance, and env-tunable gains. 2025-09-03 22:18:20 -04:00
arancormonk
e9b12b8bc6 rtl_sdr_fm: add polyphase rational resampler (L/M) enabled by default at 48 kHz (override via DSD_FME_RESAMP), integrate post-demod and update output.rate while keeping legacy upsampler as fallback. Implement tap design with L-phase gain compensation. 2025-09-03 22:02:19 -04:00
arancormonk
9e9ae95219 rtl_sdr_fm: use fast atan2 discriminator for analog mode to reduce quantization noise 2025-09-03 21:33:04 -04:00
arancormonk
86d91512bb rtl_sdr_fm: add AVX2 widening, optional combined rotate+widen, and fixed‑point linear upsampler with env flags; preserve legacy behavior by default. Fix decoding by matching legacy upsample length (NM) with tail fill and reproducing unsigned rotate semantics. 2025-09-03 21:20:41 -04:00
arancormonk
0b00832b1f rtl_sdr_fm: enable env-gated intra-block multithreading with a tiny 2-thread pool and preallocated buffers. Parallelize HB I/Q decimation and linear upsampler; add debug log when enabled. 2025-09-03 20:52:06 -04:00
arancormonk
2655fccdea rtl_sdr_fm: ring signaling and atomic annotations 2025-09-03 20:30:32 -04:00
arancormonk
ac8f17bf20 rtl_sdr_fm: guard and document bandwidth_multiplier behavior 2025-09-03 20:23:52 -04:00
arancormonk
0cb38d2c25 rtl_sdr_fm: SIMD optimize USB byte→int16 widening in callback 2025-09-03 20:20:43 -04:00
arancormonk
6fc327c3b6 rtl_sdr_fm: avoid sqrt in RMS utility (use power-domain) 2025-09-03 20:15:27 -04:00
arancormonk
00e7c51a21 rtl_sdr_fm: add a light post-demod audio low-pass filter 2025-09-03 19:19:25 -04:00
arancormonk
e2402d0328 rtl_sdr_fm: correct deemphasis coefficient derivation and make it configurable 2025-09-03 19:08:22 -04:00
arancormonk
402cef34a9 rtl_sdr_fm: improve decimation filters (half-band FIR cascade) 2025-09-03 18:53:44 -04:00
arancormonk
29be104345 rtl_sdr_fm: replace sample duplication with simple resampling (linear interpolation) 2025-09-03 18:30:38 -04:00
arancormonk
f3ec024000 rtl_sdr_fm: replace DC block with leaky integrator high-pass (IIR) 2025-09-03 18:18:00 -04:00
arancormonk
412a4dc3b1 rtl_sdr_fm: add saturating arithmetic for decimation and volume scaling 2025-09-03 18:05:28 -04:00
arancormonk
2eedcc125b rtl_sdr_fm: fix deemphasis state race 2025-09-03 18:01:06 -04:00
arancormonk
9b399f31da rtl_sdr_fm: enable vectorization and alignment for DSP arrays 2025-09-03 16:25:15 -04:00
arancormonk
2ec3f9a263 rtl_sdr_fm: hoist divisions and use integer scalers in hot loops 2025-09-03 16:14:26 -04:00
arancormonk
0decc5934c rtl_sdr_fm: add batch operations and thread scheduling 2025-09-03 15:58:33 -04:00
arancormonk
7dd9cd7566 rtl_sdr_fm: add batched consumer API 2025-09-03 15:51:45 -04:00
arancormonk
30766b34bd rtl_sdr_fm: fix timespec normalization in timed wait 2025-09-03 15:21:50 -04:00
arancormonk
e700e418be rtl_sdr_fm: make RMS squelch incremental and decimated 2025-09-03 15:17:07 -04:00
arancormonk
c6d3e4cea0 rtl_sdr_fm: removed the obsolete rwlock and lock sites 2025-09-03 15:08:19 -04:00
arancormonk
62a9372d61 rtl_sdr: make async buffer params explicit and safe 2025-09-03 15:03:38 -04:00
arancormonk
cc200ea82c rtl_sdr: make RMS squelch sqrt-free 2025-09-03 14:48:33 -04:00
arancormonk
03c6b28de3 rtl_sdr_fm: initialize async buffer length and consider buffer count 2025-09-03 14:36:26 -04:00
arancormonk
3fe14f3b1d rtl_sdr_fm: double-buffer the I/Q handoff and remove memcpy/locks between callback and demod 2025-09-03 14:30:32 -04:00
arancormonk
3adcf5f449 rtl_sdr_fm: replace std::queue + locks with a single-producer single-consumer ring buffer 2025-09-03 13:21:47 -04:00
arancormonk
b81e1e6d22 rtl_sdr_fm: fix atan2/LUT discriminator — use precise π, quadrant-correct LUT saturation, clamp ±π at wrap, and mutex-protect LUT free. 2025-09-03 10:38:52 -04:00
11 changed files with 3384 additions and 288 deletions

3
.gitignore vendored
View File

@@ -9,4 +9,5 @@ examples
*.ans
*.patch
*.zip
result
result
.cache

View File

@@ -371,7 +371,7 @@ typedef struct
int rtl_udp_port;
int rtl_bandwidth;
int rtl_started;
long int rtl_rms;
long int rtl_pwr;
int monitor_input_audio;
int analog_only;
int pulse_raw_rate_in;
@@ -960,7 +960,7 @@ typedef struct
uint8_t m17_can; //can value that was decoded from signal
int m17_can_en; //can value supplied to the encoding side
int m17_rate; //sampling rate for audio input
int m17_vox; //vox enabled via RMS value
int m17_vox; //vox enabled via PWR value
char m17_dst_csd[20];
char m17_src_csd[20];
@@ -1580,6 +1580,7 @@ void init_rrc_filter_memory();
//misc audio filtering for analog
long int raw_rms(short *samples, int len, int step);
long int raw_pwr(short *samples, int len, int step);
void init_audio_filters(dsd_state * state);
void lpf(dsd_state * state, short * input, int len);
void hpf(dsd_state * state, short * input, int len);
@@ -1660,7 +1661,7 @@ void cleanup_rtlsdr_stream();
int get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state);
void rtlsdr_sighandler();
void rtl_dev_tune(dsd_opts * opts, long int frequency);
long int rtl_return_rms();
long int rtl_return_pwr();
void rtl_clean_queue();
#endif

View File

@@ -419,8 +419,8 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
}
//if using an rtl input method, do not look for sync patterns if the rms value is lower than our 'soft squelch' level
if (opts->audio_in_type == 3 && opts->rtl_rms < opts->rtl_squelch_level)
//if using an rtl input method, do not look for sync patterns if the pwr value is lower than our 'soft squelch' level
if (opts->audio_in_type == 3 && opts->rtl_pwr < opts->rtl_squelch_level)
{
if (opts->frame_nxdn48 == 1 || opts->frame_nxdn96 == 1 || opts->frame_dpmr == 1 || opts->frame_m17 == 1)
{

View File

@@ -689,14 +689,14 @@
//all RTL user options -- enabled AGC by default due to weak signal related issues
opts->rtl_dev_index = 0; //choose which device we want by index number
opts->rtl_gain_value = 0; //mid value, 0 - AGC - 0 to 49 acceptable values
opts->rtl_squelch_level = 100; //100 by default, but only affects NXDN and dPMR during framesync test, compared to RMS value
opts->rtl_squelch_level = 10000; //default scaled for rtl_pwr (RMS^2 proxy); ~100 RMS equivalent
opts->rtl_volume_multiplier = 2; //sample multiplier; This multiplies the sample value to produce a higher 'inlvl' for the demodulator
opts->rtl_udp_port = 0; //set UDP port for RTL remote -- 0 by default, will be making this optional for some external/legacy use cases (edacs-fm, etc)
opts->rtl_bandwidth = 12; //default is 12, reverted back to normal on this (no inherent benefit)
opts->rtlsdr_ppm_error = 0; //initialize ppm with 0 value;
opts->rtlsdr_center_freq = 850000000; //set to an initial value (if user is using a channel map, then they won't need to specify anything other than -i rtl if desired)
opts->rtl_started = 0;
opts->rtl_rms = 0; //root means square power level on rtl input signal
opts->rtl_pwr = 0; // mean power approximation level on rtl input signal
//end RTL user options
opts->pulse_raw_rate_in = 48000;
opts->pulse_raw_rate_out = 48000;//
@@ -1461,7 +1461,7 @@
printf (" gain <num> RTL-SDR Device Gain (0-49)(default = 0; Hardware AGC recommended)\n");
printf (" ppm <num> RTL-SDR PPM Error (default = 0)\n");
printf (" bw <num> RTL-SDR Bandwidth kHz (default = 12)(4, 6, 8, 12, 16, 24) \n");
printf (" sq <num> RTL-SDR Squelch Level vs RMS Value (Optional)\n");
printf (" sq <num> RTL-SDR Squelch Level vs PWR Value (Optional)\n");
// printf (" udp <num> RTL-SDR Legacy UDP Remote Port (Optional -- External Use Only)\n"); //NOTE: This is still available as an option in the ncurses menu
printf (" vol <num> RTL-SDR Sample 'Volume' Multiplier (default = 2)(1,2,3)\n");
printf (" Example: dsd-fme -fs -i rtl -C cap_plus_channel.csv -T\n");
@@ -1644,8 +1644,8 @@
open_rtlsdr_stream(opts);
opts->rtl_started = 1; //set here so ncurses terminal doesn't attempt to open it again
// #ifdef __arm__
// fprintf (stderr, "WARNING: RMS Function is Disabled on ARM Devices (Raspberry Pi) due to High CPU use. \n");
// fprintf (stderr, "RMS/Squelch Functionality for NXDN, dPMR, EDACS Analog, M17 and Raw Audio Monitor are unavailable and these modes will not function properly. \n");
// fprintf (stderr, "WARNING: PWR Function is Disabled on ARM Devices (Raspberry Pi) due to High CPU use. \n");
// fprintf (stderr, "PWR/Squelch Functionality for NXDN, dPMR, EDACS Analog, M17 and Raw Audio Monitor are unavailable and these modes will not function properly. \n");
// if (opts->monitor_input_audio == 1) opts->monitor_input_audio = 0;
// opts->rtl_squelch_level = 0;
// #endif

View File

@@ -591,4 +591,28 @@ long int raw_rms(int16_t *samples, int len, int step) //use samplespersymbol as
rms = (long int)sqrt((p-err) / len);
if (rms < 0) rms = 150;
return rms;
}
/*
* Mean power (RMS^2 proxy) without sqrt, modeled after mean_power() in rtl_sdr_fm.cpp.
* Computes a DC-corrected average of squares to avoid costly sqrt operations.
*/
long int raw_pwr(int16_t *samples, int len, int step)
{
int64_t p = 0;
int64_t t = 0;
for (int i = 0; i < len; i += step) {
int64_t s = (int64_t)samples[i];
t += s;
p += s * s;
}
/* DC-corrected energy ≈ p - (t^2)/len with rounded division */
int64_t dc_corr = 0;
if (len > 0) {
int64_t tt = t * t;
dc_corr = (tt + (len / 2)) / len;
}
int64_t energy = p - dc_corr;
if (energy < 0) energy = 0;
return (long int)(energy / (len > 0 ? len : 1));
}

View File

@@ -417,7 +417,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
entry_win = newwin(8, WIDTH+22, starty+10, startx+10);
box (entry_win, 0, 0);
mvwprintw(entry_win, 2, 2, " RTL RMS Squelch Level (NXDN/dPMR/Analog/Raw only): ");
mvwprintw(entry_win, 2, 2, " RTL Power Squelch Level (NXDN/dPMR/Analog/Raw only): ");
mvwprintw(entry_win, 3, 3, " ");
echo();
refresh();
@@ -463,7 +463,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
mvwprintw(entry_win, 8, 2, " RTL Volume Multiplier: %d", opts->rtl_volume_multiplier);
mvwprintw(entry_win, 9, 2, " RTL Device UDP Port: %d", opts->rtl_udp_port);
mvwprintw(entry_win, 10, 2, " RTL Device PPM: %d", opts->rtlsdr_ppm_error);
mvwprintw(entry_win, 11, 2, " RTL RMS Squelch: %d", opts->rtl_squelch_level);
mvwprintw(entry_win, 11, 2, " RTL PWR Squelch: %d", opts->rtl_squelch_level);
mvwprintw(entry_win, 13, 2, " Are You Sure?");
mvwprintw(entry_win, 14, 2, " 1 = Yes, 2 = No ");
mvwprintw(entry_win, 15, 3, " ");

View File

@@ -255,7 +255,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw (" V: %iX;", opts->rtl_volume_multiplier);
printw (" PPM: %i;", opts->rtlsdr_ppm_error); //Adjust manually now with { and }
printw (" SQ: %i;", opts->rtl_squelch_level);
printw (" RMS: %04li;", opts->rtl_rms);
printw (" PWR: %04li;", opts->rtl_pwr);
printw (" BW: %i;", opts->rtl_bandwidth);
printw (" FRQ: %i;", opts->rtlsdr_center_freq);
if (opts->rtl_udp_port != 0) printw ("\n| External RTL Tuning on UDP Port: %i", opts->rtl_udp_port);
@@ -282,7 +282,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw ("| Pulse Analog Output: %i kHz; %i Ch; G: %02.0f%% (/|*) ", opts->pulse_raw_rate_out/1000, opts->pulse_raw_out_channels, opts->audio_gainA);
if (opts->audio_gainA == 0.0f) printw ("Auto ");
else printw ("Manual ");
if (opts->audio_in_type != 3) printw ("RMS: %04ld; ", opts->rtl_rms);
if (opts->audio_in_type != 3) printw ("PWR: %04ld; ", opts->rtl_pwr);
if (opts->use_lpf == 1) printw ("F: |LP|"); else printw ("F: | |");
if (opts->use_hpf == 1) printw ("HP|"); else printw (" |");
if (opts->use_pbf == 1) printw ("PB|"); else printw (" |");
@@ -302,7 +302,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if ( (opts->audio_out_type == 5 && opts->pulse_digi_rate_out == 48000 && opts->pulse_digi_out_channels == 1) && (opts->frame_provoice == 1 || opts->monitor_input_audio == 1) )
{
printw ("\n| Analog Monitor RMS: %04ld; G: %02.0f%% (/|*) ", opts->rtl_rms, opts->audio_gainA);
printw ("\n| Analog Monitor PWR: %04ld; G: %02.0f%% (/|*) ", opts->rtl_pwr, opts->audio_gainA);
if (opts->audio_gainA == 0.0f) printw ("Auto ");
else printw ("Manual ");
if (opts->use_lpf == 1) printw ("F: |LP|"); else printw ("F: | |");
@@ -321,14 +321,14 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->use_hpf_d == 1) printw (" HPF");
if (opts->call_alert == 1) printw (" *CA!"); //Call Alert
if ( (opts->audio_out_type == 5 && opts->pulse_digi_rate_out == 48000 && opts->pulse_digi_out_channels == 1) && (opts->frame_provoice == 1 || opts->monitor_input_audio == 1) )
printw (" - Monitor RMS: %04ld ", opts->rtl_rms);
printw (" - Monitor PWR: %04ld ", opts->rtl_pwr);
printw (" \n");
if (opts->udp_sockfdA != 0) //Analog Output on udp port +2
{
printw ("| UDP Analog Output: %s:%d; 48 kHz 1 Ch; G: %02.0f%% (/|*) ", opts->udp_hostname, opts->udp_portno+2, opts->audio_gainA);
if (opts->audio_gainA == 0.0f) printw ("A ");
else printw ("M ");
if (opts->audio_in_type != 3) printw ("RMS: %04ld; ", opts->rtl_rms);
if (opts->audio_in_type != 3) printw ("PWR: %04ld; ", opts->rtl_pwr);
if (opts->use_lpf == 1) printw ("F: |LP|"); else printw ("F: | |");
if (opts->use_hpf == 1) printw ("HP|"); else printw (" |");
if (opts->use_pbf == 1) printw ("PB|"); else printw (" |");
@@ -347,7 +347,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
if (opts->use_lpf == 1) printw ("F: |LP|"); else printw ("F: | |");
if (opts->use_hpf == 1) printw ("HP|"); else printw (" |");
if (opts->use_pbf == 1) printw ("PB|"); else printw (" |");
if (opts->audio_in_type != 3 && state->m17_vox == 1) printw ( " SQL: %04ld : %04d;", opts->rtl_rms, opts->rtl_squelch_level);
if (opts->audio_in_type != 3 && state->m17_vox == 1) printw ( " SQL: %04ld : %04d;", opts->rtl_pwr, opts->rtl_squelch_level);
printw ("\n");
}

View File

@@ -132,7 +132,7 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
if (get_rtlsdr_sample(&sample, opts, state) < 0)
cleanupAndExit(opts, state);
//update root means square power level
opts->rtl_rms = rtl_return_rms();
opts->rtl_pwr = rtl_return_pwr();
sample *= opts->rtl_volume_multiplier;
#endif
@@ -268,9 +268,9 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
if (state->analog_sample_counter == 960)
{
//get an rms value if not using the rtl built in version
//get an pwr value if not using the rtl built in version
if (opts->audio_in_type != 3 && opts->monitor_input_audio == 1)
opts->rtl_rms = raw_rms(state->analog_out, 960, 1);
opts->rtl_pwr = raw_pwr(state->analog_out, 960, 1);
//raw wav file saving -- only write when not NXDN, dPMR, or M17 due to noise that can cause tons of false positives when no sync
if (opts->wav_out_raw != NULL && opts->frame_nxdn48 == 0 && opts->frame_nxdn96 == 0 && opts->frame_dpmr == 0 && opts->frame_m17 == 0)
@@ -299,13 +299,13 @@ getSymbol (dsd_opts * opts, dsd_state * state, int have_sync)
else
agsm(opts, state, state->analog_out, 960);
//Running RMS after filtering does remove the analog spike from the RMS value
//Running PWR after filtering does remove the analog spike from the PWR value
//but noise floor noise will still produce higher values
// if (opts->audio_in_type != 3 && opts->monitor_input_audio == 1)
// opts->rtl_rms = raw_rms(state->analog_out, 960, 1);
// opts->rtl_pwr = raw_pwr(state->analog_out, 960, 1);
//seems to be working now, but RMS values are lower on actual analog signal than on no signal but noise
if ( (opts->rtl_rms > opts->rtl_squelch_level) && opts->monitor_input_audio == 1 && state->carrier == 0 ) //added carrier check here in lieu of disabling it above
//seems to be working now, but PWR values are lower on actual analog signal than on no signal but noise
if ( (opts->rtl_pwr > opts->rtl_squelch_level) && opts->monitor_input_audio == 1 && state->carrier == 0 ) //added carrier check here in lieu of disabling it above
{
if (opts->audio_out_type == 0)
pa_simple_write(opts->pulse_raw_dev_out, state->analog_out, 960*2, NULL);

View File

@@ -179,7 +179,7 @@ unsigned long long int edacsVoteFr(unsigned long long int fr_1_4, unsigned long
void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn)
{
int i, result;
int count = 5; //RMS has a 5 count (5 * 180ms) now before cutting off;
int count = 5; //PWR has a 5 count (5 * 180ms) now before cutting off;
short analog1[960];
short analog2[960];
short analog3[960];
@@ -202,7 +202,7 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
memset (d2, 0, sizeof(d2));
memset (d3, 0, sizeof(d3));
long int rms = opts->rtl_squelch_level + 1; //one more for the initial loop phase
long int pwr = opts->rtl_squelch_level + 1; //one more for the initial loop phase
long int sql = opts->rtl_squelch_level;
fprintf (stderr, "\n");
@@ -229,8 +229,8 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
pa_simple_read(opts->pulse_digi_dev_in, &sample, 2, NULL );
analog3[i] = sample;
}
//this rms will only work properly (for now) with squelch enabled in SDR++ or other
rms = raw_rms(analog3, 960, 1);
//this pwr will only work properly (for now) with squelch enabled in SDR++ or other
pwr = raw_pwr(analog3, 960, 1);
}
//NOTE: The core dumps observed previously were due to SDR++ Remote Server connection dropping due to Internet/Other issues
@@ -287,8 +287,8 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
analog3[i] = sample;
}
//this rms will only work properly (for now) with squelch enabled in SDR++
rms = raw_rms(analog3, 960, 1);
//this pwr will only work properly (for now) with squelch enabled in SDR++
pwr = raw_pwr(analog3, 960, 1);
}
//RTL Input
@@ -315,8 +315,8 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
sample *= opts->rtl_volume_multiplier;
analog3[i] = sample;
}
//the rtl rms value works properly without needing a 'hard' squelch value
rms = rtl_return_rms();
//the rtl pwr value works properly without needing a 'hard' squelch value
pwr = rtl_return_pwr();
}
#endif
@@ -387,12 +387,12 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
agsm (opts, state, analog3, 960);
}
//NOTE: Ideally, we would run raw_rms for TCP/VS here, but the analog spike on EDACS (STM)
//NOTE: Ideally, we would run raw_pwr for TCP/VS here, but the analog spike on EDACS (STM)
//system gets filtered out, and when they hold the radio open and don't talk,
//it counts against the squelch hit as no audio, so we will just have to use
//the squelch checkbox in SDR++ and similar when using those input methods
// if (opts->audio_in_type != 3)
// rms = raw_rms(analog3, 960, 1);
// pwr = raw_pwr(analog3, 960, 1);
//reconfigured to use seperate audio out stream that is always 48k short
if (opts->audio_out_type == 0 && opts->slot1_on == 1)
@@ -425,18 +425,18 @@ void edacs_analog(dsd_opts * opts, dsd_state * state, int afs, unsigned char lcn
write (opts->audio_out_fd, analog3, 960*2);
}
opts->rtl_rms = rms;
opts->rtl_pwr = pwr;
printFrameSync (opts, state, " EDACS", 0, "A");
if (rms < sql) count--;
if (pwr < sql) count--;
else count = 5;
if (rms > sql) fprintf(stderr, "%s", KGRN);
if (pwr > sql) fprintf(stderr, "%s", KGRN);
else fprintf(stderr, "%s", KRED);
fprintf (stderr, " Analog RMS: %04ld SQL: %ld", rms, sql);
fprintf (stderr, " Analog PWR: %04ld SQL: %ld", pwr, sql);
if (state->ea_mode == 0)
{
int a = (afs >> state->edacs_a_shift) & state->edacs_a_mask;
@@ -1488,7 +1488,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
//NOTE: Restructured below so that analog and digital are handled the same, just that when
//its analog, it will now start edacs_analog which will while loop analog samples until
//signal level drops (RMS, or a dotting sequence is detected)
//signal level drops (PWR, or a dotting sequence is detected)
//this is working now with the new import setup
if (opts->trunk_tune_group_calls == 1 && opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0) ) //DE is digital encrypted, B is block
@@ -1743,7 +1743,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
//NOTE: Restructured below so that analog and digital are handled the same, just that when
//its analog, it will now start edacs_analog which will while loop analog samples until
//signal level drops (RMS, or a dotting sequence is detected)
//signal level drops (PWR, or a dotting sequence is detected)
//this is working now with the new import setup
if (((is_individual == 0 && opts->trunk_tune_group_calls == 1) || (is_individual == 1 && opts->trunk_tune_private_calls == 1)) &&
@@ -1857,7 +1857,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
//NOTE: Restructured below so that analog and digital are handled the same, just that when
//its analog, it will now start edacs_analog which will while loop analog samples until
//signal level drops (RMS, or a dotting sequence is detected)
//signal level drops (PWR, or a dotting sequence is detected)
//this is working now with the new import setup
if ((opts->trunk_tune_private_calls == 1) && opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0) ) //DE is digital encrypted, B is block
@@ -2153,7 +2153,7 @@ void edacs(dsd_opts * opts, dsd_state * state)
//NOTE: Restructured below so that analog and digital are handled the same, just that when
//its analog, it will now start edacs_analog which will while loop analog samples until
//signal level drops (RMS, or a dotting sequence is detected)
//signal level drops (PWR, or a dotting sequence is detected)
//this is working now with the new import setup
if ((opts->trunk_tune_group_calls == 1) && opts->p25_trunk == 1 && (strcmp(mode, "DE") != 0) && (strcmp(mode, "B") != 0) ) //DE is digital encrypted, B is block

View File

@@ -1962,13 +1962,13 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
voice2[i] = sample;
}
}
opts->rtl_rms = rtl_return_rms();
opts->rtl_pwr = rtl_return_pwr();
#endif
}
//read in RMS value for vox function; NOTE: will not work correctly SOCAT STDIO TCP due to blocking when no samples to read
//read in power value for vox function; use mean power (RMS^2 proxy) for consistency with rtl_pwr
if (opts->audio_in_type != 3)
opts->rtl_rms = raw_rms(voice1, nsam, 1) / 2; //dividing by two so mic isn't so sensitive on vox
opts->rtl_pwr = raw_pwr(voice1, nsam, 1);
//low pass filter
if (opts->use_lpf == 1)
@@ -2010,11 +2010,11 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
agsm (opts, state, voice2, 160);
}
//NOTE: Similar to EDACS analog, if calculating raw rms here after filtering,
//NOTE: Similar to EDACS analog, if calculating raw pwr here after filtering,
//anytime the walkie-talkie is held open but no voice, the center spike is removed,
//and counts against the squelch hits making vox mode inconsistent
// if (opts->audio_in_type != 3)
// opts->rtl_rms = raw_rms(voice1, 160, 1);
// opts->rtl_pwr = raw_pwr(voice1, 160, 1);
//convert out audio input into CODEC2 (3200bps) 8 byte data stream
uint8_t vc1_bytes[8]; memset (vc1_bytes, 0, sizeof(vc1_bytes));
@@ -2080,8 +2080,8 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
m17_v1[i+16+64] = v2_bits[i];
}
//tally consecutive squelch hits based on RMS value, or reset
if (opts->rtl_rms > opts->rtl_squelch_level) sql_hit = 0;
//tally consecutive squelch hits based on PWR value, or reset
if (opts->rtl_pwr > opts->rtl_squelch_level) sql_hit = 0;
else sql_hit++; //may eventually roll over to 0 again
//if vox enabled, toggle tx/eot with sql_hit comparison
@@ -2215,10 +2215,10 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
if (use_ip == 1 && lich_cnt != 5)
fprintf (stderr, " UDP: %s:%d", opts->m17_hostname, udpport);
//debug RMS Value
//debug power value
if (state->m17_vox == 1)
{
fprintf (stderr, " RMS: %04ld", opts->rtl_rms);
fprintf (stderr, " PWR: %04ld", opts->rtl_pwr);
fprintf (stderr, " SQL HIT: %d;", sql_hit);
}
@@ -2463,10 +2463,10 @@ void encodeM17STR(dsd_opts * opts, dsd_state * state)
if (use_ip == 1 && lich_cnt != 5)
fprintf (stderr, " UDP: %s:%d", opts->m17_hostname, udpport);
//debug RMS Value
//debug power value
if (state->m17_vox == 1)
{
fprintf (stderr, " RMS: %04ld", opts->rtl_rms);
fprintf (stderr, " PWR: %04ld", opts->rtl_pwr);
fprintf (stderr, " SQL HIT: %d;", sql_hit);
}

File diff suppressed because it is too large Load Diff