Editing TutorialsWritePythonApplications

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 127: Line 127:
 
Next, two variables are defined: <code>sample_rate</code> and <code>ampl</code>. These will control sampling rate and amplitude of the signal generators.
 
Next, two variables are defined: <code>sample_rate</code> and <code>ampl</code>. These will control sampling rate and amplitude of the signal generators.
  
Before explaining the next lines, have another look at the sketched flow graph chart in the previous section: it consists of three blocks and two edges. The blocks are defined in lines 13-15: Two [http://gnuradio.org/doc/doxygen/classgr_1_1analog_1_1sig__source__f.html signal sources] are generated (called <code>src0</code> and <code>src1</code>). These sources continuously create sine waves at given frequencies (350 and 440Hz) and a given sampling rate (here 32kHz). The amplitude is controlled by the ampl variable and set to 0.1. The prefix &quot;f&quot; of the block type <code>analog.sig_source_f</code> indicates the output is of type <code>float</code>, which is a good thing because the audio sink accepts floating point samples in the range between 1 and +1. These kind of things must be taken care of by the programmer: although GNU Radio does some checks to make sure the connections make sense, there is still some things that must be taken care of manually. For example, if you wanted to feed integer samples to <code>audio.sink</code>, GNU Radio would throw an error but if you would set the amplitude in the above example to anything larger than 1, you would get a distorted signal without receiving an error.
+
Before explaining the next lines, have another look at the sketched flow graph chart in the previous section: it consists of three blocks and two edges. The blocks are defined in lines 13-15: Two [http://gnuradio.org/doc/doxygen/classgr_1_1analog_1_1sig__source__f.html signal sources] are generated (called <code>src0</code> and <code>src1</code>). These sources continuously create sine waves at given frequencies (350 and 440Hz) and a given sampling rate (here 32kHz). The amplitude is controlled by the ampl variable and set to 0.1. The prefix &quot;f&quot; of the block type <code>analog.sig_source_f</code> indicates the output is of type <code>float</code>, which is a good thing because the audio sink accepts floating point samples in the range between <s>1 and +1. These kind of things must be taken care of by the programmer: although GNU Radio does some checks to make sure the connections make sense, there is still some things that must be taken care of manually. For example, if you wanted to feed integer samples to <code>audio.sink</code>, GNU Radio would throw an error</s> but if you would set the amplitude in the above example to anything larger than 1, you would get a distorted signal without receiving an error.
  
 
The signal sink is defined in line 15: <code>audio.sink()</code> returns a block which acts as a [http://gnuradio.org/doc/doxygen/classgr_1_1audio_1_1sink.html soundcard control] and plays back any samples piped into it. As in the blocks beforehand, the sampling rate needs to be set explicitly, even though this was set already for the signal sources. GNU Radio cannot guess the correct sampling rate from the context, as it is not part of the information flow between blocks.
 
The signal sink is defined in line 15: <code>audio.sink()</code> returns a block which acts as a [http://gnuradio.org/doc/doxygen/classgr_1_1audio_1_1sink.html soundcard control] and plays back any samples piped into it. As in the blocks beforehand, the sampling rate needs to be set explicitly, even though this was set already for the signal sources. GNU Radio cannot guess the correct sampling rate from the context, as it is not part of the information flow between blocks.

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)