Crude AFC option to improve reception of mistuned signals --sq5bpf --- float_to_bits.c.orig 2016-02-03 10:33:12.579962767 +0100 +++ float_to_bits.c 2016-02-03 11:29:57.384588114 +0100 @@ -17,6 +17,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * + * 20160203: added crude AFC option --sq5bpf */ @@ -76,19 +77,29 @@ int fd, fd_out, opt; int opt_verbose = 0; + int do_afc=0; + float filter=0; + float filter_val=0.0001; + int ccounter=0; - while ((opt = getopt(argc, argv, "v")) != -1) { + while ((opt = getopt(argc, argv, "vaf:F:")) != -1) { switch (opt) { - case 'v': - opt_verbose = 1; - break; - default: - exit(2); + case 'v': + opt_verbose++; + break; + case 'a': + do_afc=1; + break; + case 'f': + filter_val=atof(optarg); + break; + default: + exit(2); } } if (argc <= optind+1) { - fprintf(stderr, "Usage: %s [-v] \n", argv[0]); + fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_averaging_coefficient] \n", argv[0]); exit(2); } @@ -112,12 +123,20 @@ exit(1); } else if (rc == 0) break; +#define MAXVAL 5.0 /* this is the maximum value we'll accept for the incoming floats */ + if ((fl>-MAXVAL)&&(fl1)) { + ccounter++; + if (ccounter>50) { printf(" AFC: %f\n",filter); ccounter=0; } + } rc = write(fd_out, bits, 2); if (rc < 0) { perror("write");