Re: [Discuss-gnuradio] proper use of start(), stop(), and wait() to interact with program flow

2016-06-29 Thread Ed Coleman
Kevin:

Thank you for the quick and complete reply, I appreciate the help!

-Ed

On Wed, Jun 29, 2016 at 11:04 AM, Kevin Reid  wrote:

> On Jun 29, 2016, at 07:50, Ed Coleman  wrote:
> > if __name__ == '__main__':
> > simpleTone().run()
> >
> > The code above works fine, however if I make the following substitution:
> >
> > if __name__ == '__main__':
> > simpleTone().start()
> > simpleTone().wait()
> > #time.sleep(3)
> > simpleTone().stop()
> >
> > The result is that the file runs, and ends after 3 seconds but no audio
> is produced.
>
> Your problem is that you're constructing three unrelated top blocks: you
> have three separate occurrences of "simpleTone()". Instead you need to
> create one and continue to use it, like so:
>
> tb = simpleTone()
> tb.start()
> ...
> tb.stop()
>
> You have another problem, too, which you will find after fixing the first
> one. .wait() means to wait for the flowgraph to finish all processing, and
> your flowgraph has no elements within it to finish such as a Head block, so
> the .stop() will never be reached.
>
> Instead, you need to proceed like this:
>
> tb = simpleTone()
> tb.start()
> # the flowgraph is now running independently
> time.sleep(3)
> tb.stop()
> tb.wait()
>
> The final .wait() is not actually necessary in this case -- what it does
> is wait for the flowgraph to finish, which will happen shortly after
> .stop() is called, but if you later wish to start the same top block again,
> you must have called .wait() before you call .start(), so always having a
> matched set of [start, stop, wait] or [start, wait, stop] is good practice.
>
>
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] proper use of start(), stop(), and wait() to interact with program flow

2016-06-29 Thread Kevin Reid
On Jun 29, 2016, at 07:50, Ed Coleman  wrote:
> if __name__ == '__main__':
> simpleTone().run()
> 
> The code above works fine, however if I make the following substitution:
> 
> if __name__ == '__main__':
> simpleTone().start()
> simpleTone().wait()
> #time.sleep(3)
> simpleTone().stop()
> 
> The result is that the file runs, and ends after 3 seconds but no audio is 
> produced.

Your problem is that you're constructing three unrelated top blocks: you have 
three separate occurrences of "simpleTone()". Instead you need to create one 
and continue to use it, like so:

tb = simpleTone()
tb.start()
...
tb.stop()

You have another problem, too, which you will find after fixing the first one. 
.wait() means to wait for the flowgraph to finish all processing, and your 
flowgraph has no elements within it to finish such as a Head block, so the 
.stop() will never be reached.

Instead, you need to proceed like this:

tb = simpleTone()
tb.start()
# the flowgraph is now running independently
time.sleep(3)
tb.stop()
tb.wait()

The final .wait() is not actually necessary in this case -- what it does is 
wait for the flowgraph to finish, which will happen shortly after .stop() is 
called, but if you later wish to start the same top block again, you must have 
called .wait() before you call .start(), so always having a matched set of 
[start, stop, wait] or [start, wait, stop] is good practice.


___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio