# Sine wave of only 3 cycles

**URL:** <https://www.ruby-forum.com/t/sine-wave-of-only-3-cycles/238828>\
**Category:** GNU Radio\
**Created:** [January 30, 2014, 11:18am UTC](https://www.ruby-forum.com/t/sine-wave-of-only-3-cycles/238828 "2014-01-30T11:18:23Z")\
**Posts on this page:** 3\
**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:** [January 30, 2014, 11:18am UTC](https://www.ruby-forum.com/t/sine-wave-of-only-3-cycles/238828/1 "2014-01-30T11:18:23Z")

</div>

Dear Sir,

A block of Signal Source (Sine) generates sine wave continuously.  
How to make it just generates 3 wave-cycle and then stop generating  
immediately.  
At the end of the flow-graph there is a File Sink. This captures data  
for  
offline processing.

Regards,  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![activecat\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c57346/32.png) [@activecat\_k](https://www.ruby-forum.com/u/activecat_k)\
**Post date:** [January 30, 2014, 1:03pm UTC](https://www.ruby-forum.com/t/sine-wave-of-only-3-cycles/238828/2 "2014-01-30T13:03:23Z")

</div>

Hi,

you can use a Head block to make the sample stream stop after a given  
number of samples. Just calculate how many samples there will be in  
three  
cycles and set the Head block’s parameter accordingly.

Greetings  
Felix

2014-01-30 Activecat [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![activecat\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c57346/32.png) [@activecat\_k](https://www.ruby-forum.com/u/activecat_k)\
**Post date:** [January 30, 2014, 1:45pm UTC](https://www.ruby-forum.com/t/sine-wave-of-only-3-cycles/238828/3 "2014-01-30T13:45:03Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Also,  
to do basic mathematical tasks you don’t have to rely on GNU Radio,  
which is a fine signal processing framework but not so much a math  
environment.

If you want to have a three period sine signal, the python is short

#import numpy as np

f\_sin = 1.0  
f\_sample = 16.0  
periods = 3.0

s\_per\_period = f\_sample/f\_sin

sinevalues = np.sin(np.linspace(0, periods_2_np.pi,  
periods\*s\_per\_period) )  
sinevalues.astype(np.float32).tofile(“filename”)

this will be the same data format as written by the file sink.

Greetings  
Marcus  
On 30.01.2014 13:02, Felix W. wrote:

> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJS6kMXAAoJEAFxB7BbsDrLvCsH/RT3cjGEe+/F/xZKATXhcT/N  
KXTcGJlR3otmGA3EUU79IF7Veel9LFBlhUXIU1OhCPn3n8QpAS0KBzTW5cBatHDb  
HsD+IRZcYN3GkpqYXwpCtaLMNJgDKuHpPXxVwg3CMOXFB6LrJ8eZmB18TGplPv0x  
+N/ijjpRXyFOUwMMyC+vQbGGWkYfEFF3tlwf7Wnt9B5E8+cevVDoTOo4/zGfInv8  
n6Ww57l7/uxRncBN+eiKdjShWhVD9xKYkonghvJJ05TBRyy4D5IODQJqo8iZlcgA  
0Q6DHZAPiBgr5rTzbAenHx48RIls7j6+HSEtMDXrHkfRrdOuYxZDgMAh8rDXXgo=  
=j9iF  
-----END PGP SIGNATURE-----
