discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

accumulating samples for processing ?


From: address@hidden
Subject: accumulating samples for processing ?
Date: Sun, 05 Apr 2020 08:36:45 +0000

I am using the opportunity of porting gr-acars to GNU Radio 3.8 to 
re-write the processing algorithm. As part of this reorganization,
I want to analyze the baseline standard deviation and detect the AM
modulated message as a rise in standard deviation (ie custom squelch).
Since there is hardly any plane flying over France at the moment, I run
the analysis from a recorded file, in which case the scheduler provides
few samples at each batch. So I want to accumulate a statistically relevant
length of samples before assessing the variance. Rather than implementing
a custom circular buffer, I want to benefit from the GNU Radio scheduler
as explained slide 7 of 
http://jmfriedt.org/slides_gnuradiodays2019/18h00%20MM%20GR%20scheduler.pdf

"not forced to consume all input -- can consume less at single-item granularity
 “leftovers” beginning of next call’s input_items"

So the work function of my sink block (no output item) is

{_N+=noutput_items;
 printf("N=%d ",_N);
 if (_N>1000)
   {consume_each (_N);
    _N=0;
    printf("_N is zero\n");// make sure counter is reset
   }
   else consume_each (0);  // accumulate more samples
 return 0;                 // noutput_items;
}   

and I am confused by the output of this block which states

N=170 N=340 N=510 N=680 N=850 N=1020 _N is zero
N=15534 _N is zero
N=170 N=340 N=510 N=680 N=850 N=1020 _N is zero
N=15534 _N is zero

so indeed once out of two sequences we accumulate up to 1000 samples,
detect the targeted number of samples is reached, consume the buffer and
reset the counter. But after resetting the counter, I get 15534 samples.
Is this indeed a behavior of the scheduler or a mistake on my side of handling
the counter ? (can hardly do anything wrong with such a simple example it
seems).

Is this the correct way of accumulating a minimum number of samples before
processing each batch ?

Thanks, Jean-Michel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]