Usrp_spectrum_sense and gr_bin_statistics_f


I’ve been looking into how usrp_spectrum_sense works and I have a
question about my understanding of how it works.

The basic idea is that is that you tune, take FFT(s?), then retune,
etc. This is done with the fft block and the stats block. My
questions are:

  1. What is input_items conceptually? I think it is a vector of
    pointers to different fft sweeps, but I could be wrong.

  2. So, is this code taking several FFTs then the for loop and
    accrue_stats finds the maximum magnitude of each of the FFT bins. Is
    that right?

  3. Could I change dwell_time to change the number of FFTs that are

  4. If I wanted to do some averaging (instead of find the max
    magnitude) could I would have to edit accrue_stats

Here’s all the relevant code from

const float *input = (const float *) input_items[0];
size_t vlen = d_max.size();

int n = 0;
int t;

while (n < noutput_items){
  switch (d_state)


     case ST_DWELL_DELAY:
       t = std::min(noutput_items - n, int(d_delay));
       for (int i = 0; i < t; i++){
           accrue_stats(&input[n * vlen]);
       d_delay -= t;
       assert(d_delay >= 0);
       if (d_delay == 0){

gr_bin_statistics_f::accrue_stats(const float *input)
for (size_t i = 0; i < vlen(); i++){
d_max[i] = std::max(d_max[i], input[i]); // compute per bin

Thanks for any help,