// // agc_crcf_example.c // // Automatic gain control example demonstrating its transient // response. // #include #include #include #include #include #include "liquid.h" #define OUTPUT_FILENAME "agc_crcf_example.m" // print usage/help message void usage() { printf("agc_example [options]\n"); printf(" h : print usage\n"); printf(" n : number of samples, n >=100, default: 2000\n"); printf(" b : AGC bandwidth, b >= 0, default: 0.01\n"); } int main(int argc, char*argv[]) { // options float bt = 0.01f; // agc loop bandwidth float gamma = 0.001f; // initial signal level unsigned int num_samples = 2000; // number of samples int dopt; while((dopt = getopt(argc,argv,"hn:N:s:b:")) != EOF){ switch (dopt) { case 'h': usage(); return 0; case 'n': num_samples = atoi(optarg); break; case 'b': bt = atof(optarg); break; default: exit(1); } } // validate input if (bt < 0.0f) { fprintf(stderr,"error: %s, bandwidth must be positive\n", argv[0]); exit(1); } else if (num_samples == 0) { fprintf(stderr,"error: %s, number of samples must be greater than zero\n", argv[0]); exit(1); } unsigned int i; // create objects agc_crcf q = agc_crcf_create(); agc_crcf_set_bandwidth(q, bt); //agc_crcf_set_scale(q, 0.5f); float complex x[num_samples]; // input float complex y[num_samples]; // output float rssi[num_samples]; // received signal strength // print info agc_crcf_print(q); // generate signal for (i=0; i