mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-19 20:27:26 -05:00
Fix RTL RMS so it does't return Jank Values;
This commit is contained in:
@@ -274,7 +274,7 @@ typedef struct
|
|||||||
int rtl_udp_port;
|
int rtl_udp_port;
|
||||||
int rtl_bandwidth;
|
int rtl_bandwidth;
|
||||||
int rtl_started;
|
int rtl_started;
|
||||||
int rtl_rms;
|
long int rtl_rms;
|
||||||
int monitor_input_audio;
|
int monitor_input_audio;
|
||||||
int pulse_raw_rate_in;
|
int pulse_raw_rate_in;
|
||||||
int pulse_raw_rate_out;
|
int pulse_raw_rate_out;
|
||||||
@@ -1179,7 +1179,7 @@ void cleanup_rtlsdr_stream();
|
|||||||
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state);
|
void get_rtlsdr_sample(int16_t *sample, dsd_opts * opts, dsd_state * state);
|
||||||
void rtlsdr_sighandler();
|
void rtlsdr_sighandler();
|
||||||
void rtl_dev_tune(dsd_opts * opts, long int frequency);
|
void rtl_dev_tune(dsd_opts * opts, long int frequency);
|
||||||
int rtl_return_rms();
|
long int rtl_return_rms();
|
||||||
void rtl_clean_queue();
|
void rtl_clean_queue();
|
||||||
#endif
|
#endif
|
||||||
//DMR TRELLIS
|
//DMR TRELLIS
|
||||||
|
|||||||
@@ -2319,7 +2319,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
printw (" Gain: %idB;", opts->rtl_gain_value);
|
printw (" Gain: %idB;", opts->rtl_gain_value);
|
||||||
printw (" PPM: %i;", opts->rtlsdr_ppm_error);
|
printw (" PPM: %i;", opts->rtlsdr_ppm_error);
|
||||||
printw (" SQ: %i;", opts->rtl_squelch_level);
|
printw (" SQ: %i;", opts->rtl_squelch_level);
|
||||||
printw (" RMS: %04i;", opts->rtl_rms);
|
printw (" RMS: %04li;", opts->rtl_rms);
|
||||||
printw (" BW: %i kHz;", opts->rtl_bandwidth);
|
printw (" BW: %i kHz;", opts->rtl_bandwidth);
|
||||||
printw (" FRQ: %i;", opts->rtlsdr_center_freq);
|
printw (" FRQ: %i;", opts->rtlsdr_center_freq);
|
||||||
if (opts->rtl_udp_port != 0) printw ("\n| External Tuning on UDP Port: %i", opts->rtl_udp_port);
|
if (opts->rtl_udp_port != 0) printw ("\n| External Tuning on UDP Port: %i", opts->rtl_udp_port);
|
||||||
|
|||||||
@@ -463,11 +463,14 @@ void dc_block_filter(struct demod_state *fm)
|
|||||||
}
|
}
|
||||||
fm->dc_avg = avg;
|
fm->dc_avg = avg;
|
||||||
}
|
}
|
||||||
|
//TODO: Fix This so we don't get random negative values in Cygwin (or 32-bit builds?)
|
||||||
int rms(int16_t *samples, int len, int step)
|
//Fixed -- I honestly think the issue is Cygwin can't keep up and if it can't run enough samples in the other thread,
|
||||||
|
//then it reports some jank values, really unsure, I've never seen the issue in Linux side though
|
||||||
|
long int rms(int16_t *samples, int len, int step)
|
||||||
/* largely lifted from rtl_power */
|
/* largely lifted from rtl_power */
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
long int rms;
|
||||||
long p, t, s;
|
long p, t, s;
|
||||||
double dc, err;
|
double dc, err;
|
||||||
|
|
||||||
@@ -481,7 +484,10 @@ int rms(int16_t *samples, int len, int step)
|
|||||||
dc = (double)(t*step) / (double)len;
|
dc = (double)(t*step) / (double)len;
|
||||||
err = t * 2 * dc - dc * dc * len;
|
err = t * 2 * dc - dc * dc * len;
|
||||||
|
|
||||||
return (int)sqrt((p-err) / len);
|
rms = (long int)sqrt((p-err) / len);
|
||||||
|
//going with a value that's easy to figure out when its done the thing
|
||||||
|
if (rms < 0){ rms = 999; } //need to text nxdn with this setup to make sure it isn't broken in Windows Cygwin now
|
||||||
|
return rms;
|
||||||
}
|
}
|
||||||
|
|
||||||
void full_demod(struct demod_state *d)
|
void full_demod(struct demod_state *d)
|
||||||
@@ -1108,13 +1114,10 @@ void rtl_dev_tune(dsd_opts * opts, long int frequency)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//return RMS value (root means square) power level -- used as soft squelch inside of framesync
|
//return RMS value (root means square) power level -- used as soft squelch inside of framesync
|
||||||
int rtl_return_rms()
|
long int rtl_return_rms()
|
||||||
{
|
{
|
||||||
int sr = 0;
|
long int sr = 0;
|
||||||
sr = rms(demod.lowpassed, demod.lp_len, 1);
|
sr = rms(demod.lowpassed, demod.lp_len, 1);
|
||||||
// 'Fix' potential negative value overflow from the rms function -- Observed in Windows builds
|
|
||||||
sr = abs(sr);
|
|
||||||
if (sr > 9999) sr = 9999;
|
|
||||||
return (sr);
|
return (sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user