diff --git a/include/dsd.h b/include/dsd.h index 83b5866..89f71bc 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -142,6 +142,7 @@ typedef struct int rtl_squelch_level; int rtl_volume_multiplier; int rtl_udp_port; + int rtl_bandwidth; int monitor_input_audio; } dsd_opts; diff --git a/src/dsd_main.c b/src/dsd_main.c index b2e33be..9870a8c 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -185,6 +185,7 @@ initOpts (dsd_opts * opts) opts->rtl_squelch_level = 0; //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' opts->rtl_udp_port = 6020; //set UDP port for RTL remote + opts->rtl_bandwidth = 48; //48000 default value } void @@ -327,7 +328,8 @@ usage () printf (" -D RTL-SDR Device Index Number\n"); printf (" -G RTL-SDR Device Gain (0-49) (default = 0 Auto Gain)\n"); printf (" -L RTL-SDR Squelch Level (0 - Open, 25 - Little, 50 - Higher)(Just have to guess really...)\n"); - printf (" -V RTL-SDR Sample Gain Multiplier (default = 1)(2-3 recommended, still testing) \n"); + printf (" -V RTL-SDR Sample Gain Multiplier (default = 1)(1-3 recommended, still testing) \n"); + printf (" -Y RTL-SDR VFO Bandwidth kHz (default = 48)(6, 8, 12, 16, 24, 48) \n"); printf (" -U RTL-SDR UDP Remote Port (default = 6020)\n"); printf ("\n"); printf ("Scanner control options:\n"); @@ -574,7 +576,7 @@ main (int argc, char **argv) exitflag = 0; 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:L:V:U:Wrl")) != -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:U:Y:Wrl")) != -1) { opterr = 0; switch (c) @@ -656,6 +658,10 @@ main (int argc, char **argv) sscanf (optarg, "%d", &opts.rtl_dev_index); break; + case 'Y': //Set rtl VFO bandwidth --recommend 6, 12, 24, 36, 48, default 48? or 12? + sscanf (optarg, "%d", &opts.rtl_bandwidth); + break; + case 'W': //monitor_input_audio if no sync opts.monitor_input_audio = 1; printf ("Monitor Source Audio if no sync detected (WIP!)\n"); @@ -689,7 +695,7 @@ main (int argc, char **argv) break; case 'c': opts.rtlsdr_center_freq = (uint32_t)atofs(optarg); - printf("Tuning to frequency: %i\n", opts.rtlsdr_center_freq); + printf("Tuning to frequency: %i Hz\n", opts.rtlsdr_center_freq); break; case 'g': sscanf (optarg, "%f", &opts.audio_gain); diff --git a/src/rtl_sdr_fm.cpp b/src/rtl_sdr_fm.cpp index 521226f..6f511e4 100644 --- a/src/rtl_sdr_fm.cpp +++ b/src/rtl_sdr_fm.cpp @@ -31,7 +31,7 @@ #include #include "dsd.h" -#define DEFAULT_SAMPLE_RATE 48000 //48000 +//#define DEFAULT_SAMPLE_RATE 48000 //moved to opts->rtl_bandwidth #define DEFAULT_BUF_LENGTH (1 * 16384) #define MAXIMUM_OVERSAMPLE 16 //16 #define MAXIMUM_BUF_LENGTH (MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH) @@ -51,6 +51,10 @@ static int atan_lut_coef = 8; #include static pthread_t socket_freq; +int rtl_bandwidth; +int bandwidth_multiplier; +int bandwidth_divisor = 48000; //divide bandwidth by this to get multiplier for the for j loop to queue.push + short int volume_multiplier; short int port; // @@ -582,7 +586,8 @@ static void *demod_thread_fn(void *arg) pthread_rwlock_wrlock(&o->rw); for (int i = 0; i < d->result_len; i++) { - o->queue.push(d->result[i]); + for (int j=0; j < bandwidth_multiplier; j++){ + o->queue.push(d->result[i]);} } pthread_rwlock_unlock(&o->rw); safe_cond_signal(&o->ready, &o->ready_m); @@ -802,7 +807,8 @@ static void *controller_thread_fn(void *arg) void dongle_init(struct dongle_state *s) { - s->rate = DEFAULT_SAMPLE_RATE; + //s->rate = DEFAULT_SAMPLE_RATE; + s->rate = rtl_bandwidth; s->gain = AUTO_GAIN; // tenths of a dB s->mute = 0; s->direct_sampling = 0; @@ -813,8 +819,10 @@ void dongle_init(struct dongle_state *s) void demod_init(struct demod_state *s) { - s->rate_in = DEFAULT_SAMPLE_RATE; - s->rate_out = DEFAULT_SAMPLE_RATE; + //s->rate_in = DEFAULT_SAMPLE_RATE; + //s->rate_out = DEFAULT_SAMPLE_RATE; + s->rate_in = rtl_bandwidth; + s->rate_out = rtl_bandwidth; s->squelch_level = 0; s->conseq_squelch = 10; s->terminate_on_squelch = 0; @@ -848,7 +856,8 @@ void demod_cleanup(struct demod_state *s) void output_init(struct output_state *s) { - s->rate = DEFAULT_SAMPLE_RATE; + //s->rate = DEFAULT_SAMPLE_RATE; + s->rate = rtl_bandwidth; pthread_rwlock_init(&s->rw, NULL); pthread_cond_init(&s->ready, NULL); pthread_mutex_init(&s->ready_m, NULL); @@ -1043,7 +1052,10 @@ void open_rtlsdr_stream(dsd_opts *opts) { struct sigaction sigact; int r; - + rtl_bandwidth = opts->rtl_bandwidth * 1000; //multiple by 1000 to get rate + //rtl_bandwidth = 48000; + bandwidth_multiplier = (bandwidth_divisor / rtl_bandwidth); //find multiple with no remainder if oddball number entered + //bandwidth_multiplier = 1; dongle_init(&dongle); demod_init(&demod); output_init(&output); @@ -1060,7 +1072,13 @@ void open_rtlsdr_stream(dsd_opts *opts) if (opts->audio_in_type == 3) { dongle.dev_index = opts->rtl_dev_index; + //rtl_bandwidth = opts->rtl_bandwidth * 1000; //multiple by 1000 to get rate + //rtl_bandwidth = 48000; + //bandwidth_multiplier = rtl_bandwidth / bandwidth_divisor; //find multiple with no remainder if oddball number entered + //bandwidth_multiplier = 1; 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 VFO Bandwidth to %d Hz\n", rtl_bandwidth); + fprintf(stderr, "Setting RTL Sample Multiplier to %d\n", bandwidth_multiplier); fprintf(stderr, "Setting RTL Squelch Level to %d\n", demod.squelch_level); port = opts->rtl_udp_port; }