Merge pull request #6 from lwvmobile/lwvmobile-patch-1

Added a few more RTL options
This commit is contained in:
lwvmobile
2022-02-01 21:41:01 -05:00
committed by GitHub
5 changed files with 41 additions and 9 deletions

View File

@@ -139,6 +139,8 @@ typedef struct
int unmute_encrypted_p25; int unmute_encrypted_p25;
int rtl_dev_index; int rtl_dev_index;
int rtl_gain_value; int rtl_gain_value;
int rtl_squelch_level;
int rtl_volume_multiplier;
} dsd_opts; } dsd_opts;
typedef struct typedef struct
@@ -287,6 +289,7 @@ typedef struct
void processDMRdata (dsd_opts * opts, dsd_state * state); void processDMRdata (dsd_opts * opts, dsd_state * state);
void processDMRvoice (dsd_opts * opts, dsd_state * state); void processDMRvoice (dsd_opts * opts, dsd_state * state);
void processAudio (dsd_opts * opts, dsd_state * state); void processAudio (dsd_opts * opts, dsd_state * state);
void playRawAudio (dsd_opts * opts, dsd_state * state); //added this one HERE HERE
void writeSynthesizedVoice (dsd_opts * opts, dsd_state * state); void writeSynthesizedVoice (dsd_opts * opts, dsd_state * state);
void playSynthesizedVoice (dsd_opts * opts, dsd_state * state); void playSynthesizedVoice (dsd_opts * opts, dsd_state * state);
void openAudioOutDevice (dsd_opts * opts, int speed); void openAudioOutDevice (dsd_opts * opts, int speed);

View File

@@ -219,9 +219,9 @@ void
playRawAudio (dsd_opts * opts, dsd_state * state) playRawAudio (dsd_opts * opts, dsd_state * state)
{ {
ssize_t result; ssize_t result;
//opts->audio_in_pa_stream = opts->audio_out_pa_stream; //no idea if this will work -> can't use PortAudio, it sucks the big one, use OSS/Alsa
//if (state->audio_out_idx > opts->delay) //if (state->audio_out_idx > opts->delay)
if (opts->audio_in_type == 3) //if set to rtl_fm, maybe it shouldn't matter but for now, using this if (1 == 1) //idk, just want it to continue
{ {
// output synthesized speech to sound card // output synthesized speech to sound card
if(opts->audio_out_type == 2) if(opts->audio_out_type == 2)
@@ -306,6 +306,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
PaError err = paNoError; PaError err = paNoError;
do do
{ {
opts->audio_out_pa_stream = opts->audio_in_pa_stream; //just seeing if anythign sticks
long available = Pa_GetStreamWriteAvailable( opts->audio_out_pa_stream ); long available = Pa_GetStreamWriteAvailable( opts->audio_out_pa_stream );
if(available < 0) if(available < 0)
err = available; err = available;

View File

@@ -595,6 +595,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->lastsynctype = 15; state->lastsynctype = 15;
return (15); return (15);
} }
else { //HERE HERE
//printf("farts \n"); //well, this is the correct place to interject and have it playback raw audio if I can figure out how to make PA play raw audio damn it
//find something else to use that isn't PortAudio, need a way to send raw audio out from here when no frame sync
}
} }
@@ -612,6 +616,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
state->offset = synctest_pos; state->offset = synctest_pos;
state->max = ((state->max) + lmax) / 2; state->max = ((state->max) + lmax) / 2;
state->min = ((state->min) + lmin) / 2; state->min = ((state->min) + lmin) / 2;
//playRawAudio (opts, state); //test here HERE HERE
if (state->samplesPerSymbol == 20) if (state->samplesPerSymbol == 20)
{ {
sprintf (state->ftype, " NXDN48 "); sprintf (state->ftype, " NXDN48 ");
@@ -737,8 +742,10 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
else else
{ {
state->lastsynctype = 17; state->lastsynctype = 17;
} }
} }
} }
if (opts->frame_dstar == 1) if (opts->frame_dstar == 1)
{ {

View File

@@ -52,8 +52,8 @@ int pretty_colors()
} }
//#include "p25p1_heuristics.h" //accidentally had this disabled when getting good NXDN, so if it breaks again, try disabling this #include "p25p1_heuristics.h" //accidentally had this disabled when getting good NXDN, so if it breaks again, try disabling this
//#include "pa_devs.h" //accidentally had this disabled when getting good NXDN, so if it breaks again, try disabling this #include "pa_devs.h" //accidentally had this disabled when getting good NXDN, so if it breaks again, try disabling this
short int butt = 1; short int butt = 1;
#include <locale.h> #include <locale.h>
#include <ncurses.h> #include <ncurses.h>
@@ -187,6 +187,8 @@ initOpts (dsd_opts * opts)
opts->unmute_encrypted_p25 = 0; opts->unmute_encrypted_p25 = 0;
opts->rtl_dev_index = 0; //choose which device we want by index number opts->rtl_dev_index = 0; //choose which device we want by index number
opts->rtl_gain_value = 0; //set actual gain and not automatic gain opts->rtl_gain_value = 0; //set actual gain and not automatic gain
opts->rtl_squelch_level = 100; //fully open by default, want to specify level for things like NXDN with false positives
opts->rtl_volume_multiplier = 1; //set multipler from rtl sample to 'boost volume'
} }
void void
@@ -322,10 +324,12 @@ usage ()
printf (" -a Display port audio devices\n"); printf (" -a Display port audio devices\n");
printf ("\n"); printf ("\n");
printf ("RTL-SDR options:\n"); printf ("RTL-SDR options:\n");
printf (" -c <hertz> RTL-SDR tune to frequency\n"); printf (" -c <hertz> RTL-SDR Frequency\n");
printf (" -P <num> RTL-SDR ppm error (default = 0)\n"); printf (" -P <num> RTL-SDR PPM Error (default = 0)\n");
printf (" -D <num> RTL-SDR Device Index Number\n"); printf (" -D <num> RTL-SDR Device Index Number\n");
printf (" -G <num> RTL-SDR Device Gain (0-49) (default = 0 Auto Gain)\n"); printf (" -G <num> RTL-SDR Device Gain (0-49) (default = 0 Auto Gain)\n");
printf (" -L <num> RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)(Just have to guess really...)\n");
printf (" -V <num> RTL-SDR Sample Gain Multiplier (default = 1)(2-3 recommended, still testing) \n");
printf ("\n"); printf ("\n");
printf ("Scanner control options:\n"); printf ("Scanner control options:\n");
printf (" -B <num> Serial port baud rate (default=115200)\n"); printf (" -B <num> Serial port baud rate (default=115200)\n");
@@ -597,7 +601,7 @@ main (int argc, char **argv)
exitflag = 0; exitflag = 0;
signal (SIGINT, sigfun); signal (SIGINT, sigfun);
while ((c = getopt (argc, argv, "haep:P:qstv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:rl")) != -1) while ((c = getopt (argc, argv, "haep:P:qstv:z:i:o:d:c:g:nw:B:C:R:f:m:u:x:A:S:M:G:D:L:V:rl")) != -1)
{ {
opterr = 0; opterr = 0;
switch (c) switch (c)
@@ -664,6 +668,16 @@ main (int argc, char **argv)
//opts->audio_in_type = 3; //opts->audio_in_type = 3;
break; break;
case 'L': //Set rtl squelch level
sscanf (optarg, "%d", &opts.rtl_squelch_level); //set squelch by user to prevent false positives on NXDN and others
//opts->audio_in_type = 3;
break;
case 'V': //Set rtl squelch level
sscanf (optarg, "%d", &opts.rtl_volume_multiplier); //set squelch by user to prevent false positives on NXDN and others
//opts->audio_in_type = 3;
break;
case 'D': //Set rtl device index number case 'D': //Set rtl device index number
sscanf (optarg, "%d", &opts.rtl_dev_index); sscanf (optarg, "%d", &opts.rtl_dev_index);
//opts->audio_in_type = 3; //opts->audio_in_type = 3;

View File

@@ -50,6 +50,8 @@ static int atan_lut_coef = 8;
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
static pthread_t socket_freq; static pthread_t socket_freq;
short int volume_multiplier;
// //
struct dongle_state struct dongle_state
{ {
@@ -1057,12 +1059,15 @@ void open_rtlsdr_stream(dsd_opts *opts)
if (opts->audio_in_type == 3) { if (opts->audio_in_type == 3) {
dongle.dev_index = opts->rtl_dev_index; dongle.dev_index = opts->rtl_dev_index;
demod.squelch_level = opts->rtl_squelch_level; //adding user definable squelch level to prevent false positives on account of noise in NXDN etc
fprintf(stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level);
} }
if (opts->rtl_gain_value > 0) { 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 really works dongle.gain = opts->rtl_gain_value * 10; //multiple by ten to make it consitent with the way rtl_fm really works
} }
volume_multiplier = opts->rtl_volume_multiplier;
fprintf(stderr, "Setting RTL Volume Multiplier to %d\n", volume_multiplier);
/* quadruple sample_rate to limit to Δθ to ±π/2 */ /* quadruple sample_rate to limit to Δθ to ±π/2 */
demod.rate_in *= demod.post_downsample; demod.rate_in *= demod.post_downsample;
@@ -1142,7 +1147,9 @@ void get_rtlsdr_sample(int16_t *sample)
safe_cond_wait(&output.ready, &output.ready_m); safe_cond_wait(&output.ready, &output.ready_m);
} }
pthread_rwlock_wrlock(&output.rw); pthread_rwlock_wrlock(&output.rw);
*sample = output.queue.front(); //*sample = output.queue.front();
*sample = output.queue.front() * volume_multiplier; //try multiplying by numbers here for 'gain'
output.queue.pop(); output.queue.pop();
pthread_rwlock_unlock(&output.rw); pthread_rwlock_unlock(&output.rw);
} }