# Consuming all inputs, small outputs

**URL:** <https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883>\
**Category:** GNU Radio\
**Created:** [January 19, 2015, 9:25pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883 "2015-01-19T21:25:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [January 19, 2015, 9:25pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883/1 "2015-01-19T21:25:37Z")

</div>

I am trying to create a block that outputs one number from each chucnk  
of  
data it takes in, I would like to output this number and be able to use  
it  
in visualizations, what would the best block be for this? Would a  
decimation block work? what if I would like to out put three numbers  
from  
one chunk of input and visualize those (lets say I’m doing an  
autocorellation and would like to know sample number I found the  
highest  
correlation and the size of the correlation peak) and I want to plot  
them.  
Thanks, I’m finding this all REALLY confusing and every time I try  
something I am just running in to problems

---

<div class="post-metadata">

**Author:** ![jon\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jon\_w](https://www.ruby-forum.com/u/jon_w)\
**Post date:** [January 19, 2015, 9:40pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883/2 "2015-01-19T21:40:16Z")

</div>

> I am trying to create a block that outputs one number from each chucnk of  
> data it takes in, I would like to output this number and be able to use it  
> in visualizations, what would the best block be for this? Would a decimation  
> block work? what if I would like to out put three numbers from one chunk of  
> input and visualize those (lets say I’m doing an autocorellation and would  
> like to know sample number I found the highest correlation and the size of  
> the correlation peak) and I want to plot them. Thanks, I’m finding this all  
> REALLY confusing and every time I try something I am just running in to  
> problems

If the output is not a “flow”, then you probably want to use a message  
port and not a normal port.

Normal ports are really meant for streaming sample data and they’re  
optimized for this with among other things buffering and so if you  
only produce a very few output, those might end up being buffered for  
a very long time before being given to the next block.

Another option is sometime not to ‘output’ anything, but just have the  
sample stream pass through your block and just ‘tag’ some samples. The  
corr\_and\_sync block does that. It searches for a training sequence in  
an input stream and tags where it find one. So the next block in the  
chain can take this input stream and know that at this particular  
sample, there was a correlation peak and it had this value and  
estimated frequency error. (note that this is correlation with a  
training sequence, not autocorrelation so might not be applicable to  
your case).

Cheers,

Sylvain

---

<div class="post-metadata">

**Author:** ![jon\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jon\_w](https://www.ruby-forum.com/u/jon_w)\
**Post date:** [January 19, 2015, 9:40pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883/3 "2015-01-19T21:40:54Z")

</div>

Hi Jon,

On 01/19/2015 09:24 PM, Jon W. wrote:

> I am trying to create a block that outputs one number from each chucnk  
> of data it takes in, I would like to output this number and be able to  
> use it in visualizations, what would the best block be for this?  
> Sounds like a “keep 1 in N” situation, so maybe that; documentation at  
> [1].  
> Would a decimation block work?  
> Yes. you could for example use a decimating FIR filter (if you don’t  
> want to write a block of your own), and just set the taps to [1.0], if  
> you just want to keep the numbers as they were in the original sample  
> stream. Of course, if you want to do decimation, you’d just try to use  
> an appropriate low pass filter.  
> what if I would like to out put three numbers from one chunk of input  
> and visualize those (lets say I’m doing an autocorellation and would  
> like to know sample number I found the highest correlation and the  
> size of the correlation peak) and I want to plot them.  
> Well, [2] is “keep M in N”.  
> Thanks, I’m finding this all REALLY confusing and every time I try  
> something I am just running in to problems.  
> Hope you have your little moments of success in between 🙂

Greetings,  
Marcus

[1]

> **[GNU Radio Manual and C++ API Reference: gr::blocks::keep\_one\_in\_n Class...](https://www.gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1keep __one__ in__n.html)**

[2]

> **[GNU Radio Manual and C++ API Reference: gr::blocks::keep\_m\_in\_n Class Reference](https://www.gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1keep __m__ in__n.html)**

---

<div class="post-metadata">

**Author:** ![jon\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jon\_w](https://www.ruby-forum.com/u/jon_w)\
**Post date:** [January 19, 2015, 10:11pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883/4 "2015-01-19T22:11:28Z")

</div>

Hi Jon,

um, which tutorial block are you referring to?

noutput\_items[0] is the _maximum_ number of items your work function  
call is allowed to produce (on output stream 0); you can produce less.  
ninput\_items[0] is the number of items ready for processing (on input  
stream 0); you can consume less, and will be presented with the  
remainder plus items that might have come in in the meantime.

So the point here is that general\_work of general\_block doesn’t make any  
assumptions on the relationship between the number of items you consume  
and produce; if you have a sync\_block, for comparison, there’s always a  
take-N-give-N relationship.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![jon\_w](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jon\_w](https://www.ruby-forum.com/u/jon_w)\
**Post date:** [January 19, 2015, 10:06pm UTC](https://www.ruby-forum.com/t/consuming-all-inputs-small-outputs/233883/5 "2015-01-19T22:06:23Z")

</div>

Well in regards to the general block, in my attempts at learning, I  
noticed  
that noutput\_items is less than ninput\_items, what happens to the  
samples  
not used? I just ask because the tutorial block is a general block

On Mon, Jan 19, 2015 at 3:39 PM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
