# Dynamically changing input index of Selector block

**URL:** <https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012>\
**Category:** GNU Radio\
**Created:** [May 27, 2014, 9:09am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012 "2014-05-27T09:09:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/7993a0/32.png) [@jason\_sam](https://www.ruby-forum.com/u/jason_sam)\
**Post date:** [May 27, 2014, 9:09am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/1 "2014-05-27T09:09:02Z")

</div>

Hi all,

In my flow graph I am using two different inputs. At particular time,  
only  
one input is selected.  
For this I am using ‘Selector’ block with two inputs and only one  
output.

I want to change ‘input index’ of ‘Selector’ block when flow graph is  
running. I used ‘WX GUI Slider’ block, it works but each time I have to  
change input index manually from top\_block window.

My GRC flow graph design is as follows:

Two different signal sources =\> selector (with 2 input & 1 output) =\>  
scope

Now I want to change input index of ‘Selector’ block automatically so  
that  
for fixed time 1st input is selected and then 2nd.

Please help me how to do this ?

Thanks and Regards,

Dushyant

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550.html](http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 28, 2014, 3:15pm UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/2 "2014-05-28T15:15:13Z")

</div>

On Tue, May 27, 2014 at 3:07 PM, dushyant.marathe  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> wrote:

> My GRC flow graph design is as follows:
> 
> Two different signal sources =\> selector (with 2 input & 1 output) =\> scope
> 
> Now I want to change input index of ‘Selector’ block automatically so that  
> for fixed time 1st input is selected and then 2nd.

You may try to use Stream Mux, not Selector.  
When its Lengths is determined correctly, it select 1st input for a  
predetermined fixed time, then select 2nd input.  
In this case the second number of Length is a big number, approximate  
infinity.

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 29, 2014, 9:00am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/3 "2014-05-29T09:00:11Z")

</div>

Hi Activecat,

Thanks for the reply.

As suggested by you, I used “Stream Mux” and it worked for me.

Now I want to de-multiplex the output of “Stream Mux” so as to get back  
both  
the inputs separately.

If you have any suggestions, please let me know.

Thanks and Regards,  
Dushyant

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550p48614.html](http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550p48614.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 29, 2014, 10:34am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/4 "2014-05-29T10:34:30Z")

</div>

On Thu, May 29, 2014 at 2:59 PM, dushyant.marathe  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> wrote:

> Hi Activecat,
> 
> Thanks for the reply.
> 
> As suggested by you, I used “Stream Mux” and it worked for me.
> 
> Now I want to de-multiplex the output of “Stream Mux” so as to get back  
> both  
> the inputs separately.

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Use both “Head” and “Skip Head” blocks in parallel.

For example, the Head block let you get the first 1000 elements.  
The “Skip Head” block let you get elements 1001 onwards.

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 30, 2014, 10:59am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/5 "2014-05-30T10:59:03Z")

</div>

Hi Activecat,

I used both “Head” and “Skip Head” blocks in parallel to separate out  
multiplexed input stream.  
The Head block correctly gives me first 240k elements but, “Skip Head”  
block doesn’t give me any elements after skipping 240k elements. For  
your  
reference I have attached image of my flow graph (Head\_Skip\_Head.jpg).

[http://gnuradio.4.n7.nabble.com/file/n48637/Head\_Skip\_Head.jpg](http://gnuradio.4.n7.nabble.com/file/n48637/Head_Skip_Head.jpg)

Moreover when I used “Skip Head” block alone, it gives me correctly all  
the  
elements after skipping 240k elements.

Why is it so ? I could not find out. Please give me some insight.

Thanks & Regards,  
Dushyant

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550p48637.html](http://gnuradio.4.n7.nabble.com/Dynamically-changing-input-index-of-Selector-block-tp48550p48637.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 30, 2014, 11:17am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/6 "2014-05-30T11:17:48Z")

</div>

On Fri, May 30, 2014 at 4:57 PM, dushyant.marathe  
\<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> wrote:

> Moreover when I used “Skip Head” block alone, it gives me correctly all the  
> elements after skipping 240k elements.
> 
> Why is it so ? I could not find out. Please give me some insight.

Try with “File Sink” first instead of “Wave File Sink”, this may make a  
difference.

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 31, 2014, 5:33am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/7 "2014-05-31T05:33:26Z")

</div>

On Fri, May 30, 2014 at 10:20 PM, Mike J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> FYI, the head block “copies the first N items to the output then signals  
> done”:  
> [GNU Radio Manual and C++ API Reference: gr::blocks::head Class Reference](http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1head.html)
> 
> Instead of using the “Head” block, the “Keep M in N” block should do the  
> trick.

You know your requirements well, let’s pick whichever suits you best.

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 31, 2014, 11:39am UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/8 "2014-05-31T11:39:10Z")

</div>

Problem being is that as soon as the head block signals “done”, the  
flowgraph might come to a halt, effectively breaking the skip head  
subgraph;  
how many samples are still produced after head is done depends on timing  
and buffer size…  
I think that’s why Mike recommended the “M in N”, so you only have one  
runtime-limiting block in your flowgraph.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 31, 2014, 3:16pm UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/9 "2014-05-31T15:16:55Z")

</div>

On Sat, May 31, 2014 at 5:37 PM, Marcus Müller  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Problem being is that as soon as the head block signals “done”, the  
> flowgraph might come to a halt, effectively breaking the skip head  
> subgraph;

Thanks for highlighting this.  
Now I recall that the Head block return -1 when it is done.  
This makes a very good sense to use alternative likes “M in N” block.  
Thanks.

---

<div class="post-metadata">

**Author:** ![dushyant.marathe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/5f8ce5/32.png) [@dushyant.marathe](https://www.ruby-forum.com/u/dushyant.marathe)\
**Post date:** [May 30, 2014, 4:22pm UTC](https://www.ruby-forum.com/t/dynamically-changing-input-index-of-selector-block/230012/10 "2014-05-30T16:22:28Z")

</div>

FYI, the head block “copies the first N items to the output then signals  
done”:

[http://gnuradio.org/doc/doxygen/classgr\_1\_1blocks\_1\_1head.html](http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1head.html)

Instead of using the “Head” block, the “Keep M in N” block should do the  
trick.

Mike

–  
Mike J. M0MIK BSc MIET  
Ettus R. Technical Support  
Email: removed\_email\_address@domain.invalid  
Web: [http://ettus.com](http://ettus.com)
