# Decimation of multiple streams

**URL:** <https://www.ruby-forum.com/t/decimation-of-multiple-streams/234470>\
**Category:** GNU Radio\
**Created:** [March 7, 2015, 1:10am UTC](https://www.ruby-forum.com/t/decimation-of-multiple-streams/234470 "2015-03-07T01:10:34Z")\
**Posts on this page:** 3\
**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:** [March 7, 2015, 1:10am UTC](https://www.ruby-forum.com/t/decimation-of-multiple-streams/234470/1 "2015-03-07T01:10:34Z")

</div>

Hey guys,

I just had a quick question; if we have multiple streams that need to be  
decimated, is there a fast way to go about doing that in GNURadio  
Companion? How would you do it?

Here’s a picture of my flow graph: [http://imgur.com/a/a0KCX](http://imgur.com/a/a0KCX)

Thank you for your help!

Best,  
Ali

---

<div class="post-metadata">

**Author:** ![alirose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@alirose](https://www.ruby-forum.com/u/alirose)\
**Post date:** [March 7, 2015, 10:12am UTC](https://www.ruby-forum.com/t/decimation-of-multiple-streams/234470/2 "2015-03-07T10:12:37Z")

</div>

Hi Ali,

no, there’s no easy way to have N identical things in GRC.  
However, I’m pretty sure you’re misusing vector\_to\_streamS.  
There’s vector\_to\_streamS and vector\_to\_stream, and the second is what  
you usually want when converting a vector to streams of samples.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![alirose](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@alirose](https://www.ruby-forum.com/u/alirose)\
**Post date:** [March 11, 2015, 10:07pm UTC](https://www.ruby-forum.com/t/decimation-of-multiple-streams/234470/3 "2015-03-11T22:07:52Z")

</div>

Hey Marcus,

So after some thought, I was able to figure out how to do the decimation  
for multiple streams. I’m sure most of the gurus on this list already  
know  
how to do it, but just thought about sharing my 2 cents on how I  
approached  
it so that anybody who’s still having a similar difficulty can easily  
solve  
it.

So I basically used the concept of the hierarchy block and started off  
with  
a simple example where I had three streams passing through a constant  
multiplier block. What I wanted to do was make the generation of these  
blocks and connections dynamic for as many streams as I see want, so I  
decided to adjust the python code generated from the hierarchy block,  
and  
it turned out to be a really simple fix. I simply added the following,  
and  
obviously deleted the redundant part of the code:

self.blocks\_multiply\_const\_vxx = [0]\*num\_streams

for i in range(num\_streams):  
self.blocks\_multiply\_const\_vxx[i] =  
blocks.multiply\_const\_vff((2, ))  
self.connect((self.blocks\_multiply\_const\_vxx[i], 0), (self, i))  
self.connect((self, i), (self.blocks\_multiply\_const\_vxx[i], 0))

where num\_streams is the number of streams I want. So just using this  
simple idea, I was able to extend it to the decimation for multiple  
streams. I’ve also taken some screenshots so that anyone who’s  
interested  
can see how I got about to do it: [http://imgur.com/a/a0KCX](http://imgur.com/a/a0KCX)

Best,  
Ali

On Sat, Mar 7, 2015 at 3:11 AM, Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
