# Notion of buffering up input data in GNURadio

**URL:** <https://www.ruby-forum.com/t/notion-of-buffering-up-input-data-in-gnuradio/242077>\
**Category:** GNU Radio\
**Created:** [May 25, 2015, 9:04am UTC](https://www.ruby-forum.com/t/notion-of-buffering-up-input-data-in-gnuradio/242077 "2015-05-25T09:04:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [May 25, 2015, 9:04am UTC](https://www.ruby-forum.com/t/notion-of-buffering-up-input-data-in-gnuradio/242077/1 "2015-05-25T09:04:49Z")

</div>

* * *

Discuss-gnuradio mailing list  
removed\_email\_address@domain.invalid  
[https://lists.gnu.org/mailman/listinfo/discuss-gnuradio](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

---

<div class="post-metadata">

**Author:** ![anil\_y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@anil\_y](https://www.ruby-forum.com/u/anil_y)\
**Post date:** [May 25, 2015, 8:50pm UTC](https://www.ruby-forum.com/t/notion-of-buffering-up-input-data-in-gnuradio/242077/2 "2015-05-25T20:50:30Z")

</div>

Hi Anil

On 05/25/2015 09:03 AM, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ???I have a block that involves collecting samples in a buffer, once  
> buffer is full, start processing the data (slide a window over it etc  
> etc).
> 
> My question is how does this whole concept of buffering work?  
> So, you’re writing that application and ask us how your buffering works?  
> that doesn’t sound right, so maybe I’m misunderstanding you?  
> Can I say I need len(buffer) number of samples (assuming that buffer  
> is the name of the array over which I slide my window etc) i???n the  
> forecast function and then just copy input\_items[0] into buffer in  
> every work call? What if in some iterations I don’t need to copy  
> len(buffer) elements? For example if I only need to copy one or two  
> window lengths worth data while other windows are still under process.  
> Can I still do that?  
> I think you should really read the guided tutorials I’ve linked to in my  
> last email; you’re trying to replicated functionality that is central to  
> GNU Radio.  
> GNU Radio cares for your block’s in- and output buffers. Unless your  
> work explicitly consumes input items (e.g. by returning a positive  
> number), GNU Radio accumulates the samples in your input buffer.
> 
> My second question is, how do I account for the data that comes in  
> while I’m still processing data in buffer? Do I need a second buffer  
> to accumulate subsequent data while processing buffer is full?  
> Don’t you care, GNU Radio does that for you!  
> When your work() is called, GNU Radio knows how many items you can  
> consume (from the input) and how many you can produce (on the output) –  
> your job as a developer is just writing an algorithm that can work on an  
> array of samples that lies sequentially in memory.  
> If you know how much items you need at once (e.g. you always need 127)  
> you can use set\_output\_multiple (which will inherently set the input  
> multiple on a sync block, i.e. any block with a work(), not a  
> general\_work()), and GNU Radio will only call you if there’s at least  
> 127 items of input.

Whilst your block is working on its input, new input might already occur  
from the block upstream – that’s no problem at all (in fact, it’s  
what’s pretty awesome about the current GNU Radio scheduler). Right  
after your current work() call is finished (i.e. has "return"ed), work()  
will be called again, with whatever you left untouched of the input from  
last time plus the new items.

Best regards,  
Marcus
