Re: accumulating samples for processing ?

2020-04-05 Thread jean-michel.fri...@femto-st.fr
beautiful, thanks: adding
#define CHUNK_SIZE 1024   
set_output_multiple(CHUNK_SIZE);
to the constructor yields resonable results
N=1024: _N is zero
N=1024: _N is zero
N=1024: _N is zero
N=1024: _N is zero

Still not sure why my original option was not working, but this is
definitely a fine solution. I had forgotten you previous post on the topic,

Thanks, JM

--
JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe,
25000 Besancon, France

April 5, 2020 10:58 AM, "Ron Economos"  wrote:

> I would use set_output_multiple() instead. See my previous e-mail for an 
> example.
> 
> https://lists.gnu.org/archive/html/discuss-gnuradio/2019-08/msg00188.html
> 
> Ron
> 
> On 4/5/20 01:36, jean-michel.fri...@femto-st.fr wrote:
> 
>> 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 MM 
>> GR scheduler.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



Re: accumulating samples for processing ?

2020-04-05 Thread Ron Economos
I would use set_output_multiple() instead. See my previous e-mail for an 
example.


https://lists.gnu.org/archive/html/discuss-gnuradio/2019-08/msg00188.html

Ron

On 4/5/20 01:36, jean-michel.fri...@femto-st.fr wrote:

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