mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-09 15:27:22 -05:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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, " ");
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
22
src/m17.c
22
src/m17.c
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3744,10 +3744,10 @@ void open_rtlsdr_stream(dsd_opts *opts)
|
||||
}
|
||||
|
||||
dongle.dev_index = opts->rtl_dev_index;
|
||||
// demod.squelch_level = opts->rtl_squelch_level; //no longer used here, used in framesync vc rms value under select conditions
|
||||
// demod.squelch_level = opts->rtl_squelch_level; //no longer used here, used in framesync vc pwr value under select conditions
|
||||
fprintf (stderr, "Setting RTL Bandwidth to %d Hz\n", rtl_bandwidth);
|
||||
// fprintf (stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier);
|
||||
fprintf (stderr, "Setting RTL RMS Squelch Level to %d\n", opts->rtl_squelch_level);
|
||||
fprintf (stderr, "Setting RTL Power Squelch Level to %d\n", opts->rtl_squelch_level);
|
||||
if (opts->rtl_udp_port != 0) port = opts->rtl_udp_port; //set this here, only open socket thread if set
|
||||
if (opts->rtl_gain_value > 0) {
|
||||
dongle.gain = opts->rtl_gain_value * 10; //multiple by ten to make it consitent with the way rtl_fm works
|
||||
@@ -3971,28 +3971,19 @@ void rtl_dev_tune(dsd_opts * opts, long int frequency)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return mean power approximation for soft squelch decisions.
|
||||
* Return mean power approximation (RMS^2 proxy) for soft squelch decisions.
|
||||
* Uses a small fixed sample window for efficiency.
|
||||
*
|
||||
* @return Mean power value.
|
||||
* @return Mean power value (approximate RMS squared).
|
||||
*/
|
||||
long int rtl_return_rms(void)
|
||||
long int rtl_return_pwr(void)
|
||||
{
|
||||
long int sr = 0;
|
||||
// #ifdef __arm__
|
||||
// sr = 100;
|
||||
// #else
|
||||
//debug -- on main machine, lp_len is around 6420, so this probably contributes to very high CPU usage
|
||||
// fprintf (stderr, "LP_LEN: %d \n", demod.lp_len);
|
||||
//I've found that just using a sample size of 160 will give us a good approximation without killing the CPU
|
||||
// Return mean power (squared RMS) for soft squelch decisions (sqrt-free)
|
||||
// sr = mean_power(demod.lowpassed, demod.lp_len, 1);
|
||||
long int pwr = 0;
|
||||
int n = demod.lp_len;
|
||||
if (n > 160) n = 160;
|
||||
if (n < 0) n = 0;
|
||||
sr = mean_power(demod.lowpassed, n, 1);
|
||||
// #endif
|
||||
return (sr);
|
||||
pwr = mean_power(demod.lowpassed, n, 1);
|
||||
return (pwr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user