mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2025-01-13 11:47:21 +01:00
rtl_fm: fix auto/manual gain
Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
c792c4aeac
commit
f4a8a570c4
17
src/rtl_fm.c
17
src/rtl_fm.c
@ -60,6 +60,7 @@
|
||||
#define MINIMAL_BUF_LENGTH 512
|
||||
#define MAXIMAL_BUF_LENGTH (256 * 16384)
|
||||
#define CONSEQ_SQUELCH 4
|
||||
#define AUTO_GAIN -100
|
||||
|
||||
static pthread_t demod_thread;
|
||||
static sem_t data_ready;
|
||||
@ -103,7 +104,7 @@ void usage(void)
|
||||
"\t (use multiple -f for scanning)\n"
|
||||
"\t[-s samplerate (default: 24000 Hz)]\n"
|
||||
"\t[-d device_index (default: 0)]\n"
|
||||
"\t[-g tuner_gain (default: -1dB)]\n"
|
||||
"\t[-g tuner_gain (default: automatic)]\n"
|
||||
"\t[-l squelch_level (default: 150)]\n"
|
||||
"\t[-E freq sets lower edge (default: center)]\n"
|
||||
"\tfilename (a '-' dumps samples to stdout)\n\n"
|
||||
@ -439,7 +440,7 @@ int main(int argc, char **argv)
|
||||
char *filename = NULL;
|
||||
int n_read;
|
||||
int r, opt;
|
||||
int i, gain = -10; // tenths of a dB
|
||||
int i, gain = AUTO_GAIN; // tenths of a dB
|
||||
uint8_t *buffer;
|
||||
uint32_t dev_index = 0;
|
||||
int device_count;
|
||||
@ -538,11 +539,19 @@ int main(int argc, char **argv)
|
||||
build_fir(&fm);
|
||||
|
||||
/* Set the tuner gain */
|
||||
if (gain == AUTO_GAIN) {
|
||||
r = rtlsdr_set_tuner_gain_mode(dev, 0);
|
||||
} else {
|
||||
r = rtlsdr_set_tuner_gain_mode(dev, 1);
|
||||
r = rtlsdr_set_tuner_gain(dev, gain);
|
||||
if (r < 0)
|
||||
}
|
||||
if (r != 0) {
|
||||
fprintf(stderr, "WARNING: Failed to set tuner gain.\n");
|
||||
else
|
||||
} else if (gain == AUTO_GAIN) {
|
||||
fprintf(stderr, "Tuner gain set to automatic.\n");
|
||||
} else {
|
||||
fprintf(stderr, "Tuner gain set to %0.2f dB.\n", gain/10.0);
|
||||
}
|
||||
|
||||
if(strcmp(filename, "-") == 0) { /* Write samples to stdout */
|
||||
fm.file = stdout;
|
||||
|
Loading…
Reference in New Issue
Block a user