# How to define a minimum number of input samples for a block

**URL:** <https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373>\
**Category:** GNU Radio\
**Created:** [April 1, 2015, 7:06pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373 "2015-04-01T19:06:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 1, 2015, 7:06pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373/1 "2015-04-01T19:06:24Z")

</div>

Hi,

I’m developing a block that need a minimum number of input samples to  
process, for example, the block must have at least 1000 samples.

In the work() function may I compare if the ninput\_items[] is greater  
than  
1000 and if not I return zero?  
Should I need to create an internal buffer (history) to cumulate samples  
if  
the number of samples provided was less that 1000, and the work() will  
return 0?  
There is any other way to configure the block to work with a minimum  
number  
of samples?

Thank you.

Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_Mazzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Daniel\_Mazzer](https://www.ruby-forum.com/u/Daniel_Mazzer)\
**Post date:** [April 1, 2015, 8:21pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373/2 "2015-04-01T20:21:48Z")

</div>

Hi Martin,

Thank you, I will try.  
My block is asymmetric, for n input samples it will have always 4 output  
samples.  
So I thinking that if I configure the previous block as you suggested,  
it  
will work, right?

Regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![Daniel\_Mazzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Daniel\_Mazzer](https://www.ruby-forum.com/u/Daniel_Mazzer)\
**Post date:** [April 1, 2015, 7:21pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373/3 "2015-04-01T19:21:28Z")

</div>

[http://gnuradio.org/doc/doxygen/classgr\_1\_1block.html#a65cfc579150dc4d10c6180d3365aa9a8](http://gnuradio.org/doc/doxygen/classgr_1_1block.html#a65cfc579150dc4d10c6180d3365aa9a8)

M

---

<div class="post-metadata">

**Author:** ![Daniel\_Mazzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Daniel\_Mazzer](https://www.ruby-forum.com/u/Daniel_Mazzer)\
**Post date:** [April 1, 2015, 11:43pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373/4 "2015-04-01T23:43:24Z")

</div>

On 01.04.2015 11:19, Daniel Mazzer wrote:

> Hi Martin,
> 
> Thank you, I will try.  
> My block is asymmetric, for n input samples it will have always 4 output  
> samples.  
> So I thinking that if I configure the previous block as you suggested,  
> it will work, right?

In that case, you want something else:

Make your block an ‘sync\_interpolator’ with an interpolation rate of 4.  
Then, in your work() function, you only get noutput\_items, and the  
number of input items is implicitly noutput\_items/4.

M

---

<div class="post-metadata">

**Author:** ![Daniel\_Mazzer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Daniel\_Mazzer](https://www.ruby-forum.com/u/Daniel_Mazzer)\
**Post date:** [April 6, 2015, 3:34pm UTC](https://www.ruby-forum.com/t/how-to-define-a-minimum-number-of-input-samples-for-a-block/241373/5 "2015-04-06T15:34:43Z")

</div>

Hi Martin,

Ok, it really makes sense.  
I will modify my block and try that way.

Thank you.

Regards,  
Daniel.
