Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 6e7a2755bd78c9deedab199b86e675f3 > files > 4421

gnuradio-doc-3.2.2-9.fc14.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>GNU Radio 3.2.2 C++ API: gr_fxpt_nco.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">GNU Radio 3.2.2 C++ API</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('gr__fxpt__nco_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<h1>gr_fxpt_nco.h</h1>  </div>
</div>
<div class="contents">
<a href="gr__fxpt__nco_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c++ -*- */</span>
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright 2002,2004 Free Software Foundation, Inc.</span>
<a name="l00004"></a>00004 <span class="comment"> * </span>
<a name="l00005"></a>00005 <span class="comment"> * This file is part of GNU Radio</span>
<a name="l00006"></a>00006 <span class="comment"> * </span>
<a name="l00007"></a>00007 <span class="comment"> * GNU Radio is free software; you can redistribute it and/or modify</span>
<a name="l00008"></a>00008 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00009"></a>00009 <span class="comment"> * the Free Software Foundation; either version 3, or (at your option)</span>
<a name="l00010"></a>00010 <span class="comment"> * any later version.</span>
<a name="l00011"></a>00011 <span class="comment"> * </span>
<a name="l00012"></a>00012 <span class="comment"> * GNU Radio is distributed in the hope that it will be useful,</span>
<a name="l00013"></a>00013 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00014"></a>00014 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00015"></a>00015 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00016"></a>00016 <span class="comment"> * </span>
<a name="l00017"></a>00017 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00018"></a>00018 <span class="comment"> * along with GNU Radio; see the file COPYING.  If not, write to</span>
<a name="l00019"></a>00019 <span class="comment"> * the Free Software Foundation, Inc., 51 Franklin Street,</span>
<a name="l00020"></a>00020 <span class="comment"> * Boston, MA 02110-1301, USA.</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022 <span class="preprocessor">#ifndef INCLUDED_GR_FXPT_NCO_H</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span><span class="preprocessor">#define INCLUDED_GR_FXPT_NCO_H</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;<a class="code" href="gr__fxpt_8h.html">gr_fxpt.h</a>&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;gr_complex.h&gt;</span>
<a name="l00027"></a>00027 <span class="comment"></span>
<a name="l00028"></a>00028 <span class="comment">/*!</span>
<a name="l00029"></a>00029 <span class="comment"> * \brief Numerically Controlled Oscillator (NCO)</span>
<a name="l00030"></a>00030 <span class="comment"> * \ingroup misc</span>
<a name="l00031"></a>00031 <span class="comment"> */</span>
<a name="l00032"></a><a class="code" href="classgr__fxpt__nco.html">00032</a> <span class="keyword">class </span><a class="code" href="classgr__fxpt__nco.html" title="Numerically Controlled Oscillator (NCO)">gr_fxpt_nco</a> {
<a name="l00033"></a>00033   <a class="code" href="gr__types_8h.html#a89e5afa41619bc5b0694d38709297d47">gr_uint32</a>     d_phase;
<a name="l00034"></a>00034   <a class="code" href="gr__types_8h.html#ac07cda22882f844c0aa1633d49f1c144">gr_int32</a>      d_phase_inc;
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">public</span>:
<a name="l00037"></a><a class="code" href="classgr__fxpt__nco.html#ad1845ead59d543ef212fedab1638aa97">00037</a>   <a class="code" href="classgr__fxpt__nco.html#ad1845ead59d543ef212fedab1638aa97">gr_fxpt_nco</a> () : d_phase (0), d_phase_inc (0) {}
<a name="l00038"></a>00038 
<a name="l00039"></a><a class="code" href="classgr__fxpt__nco.html#a212b5723fb480e5b151edf82c1a9648e">00039</a>   <a class="code" href="classgr__fxpt__nco.html#a212b5723fb480e5b151edf82c1a9648e">~gr_fxpt_nco</a> () {}
<a name="l00040"></a>00040 
<a name="l00041"></a>00041   <span class="comment">// radians</span>
<a name="l00042"></a><a class="code" href="classgr__fxpt__nco.html#a2a51544852b6c4d26517f9e399f73ca3">00042</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a2a51544852b6c4d26517f9e399f73ca3">set_phase</a> (<span class="keywordtype">float</span> angle) {
<a name="l00043"></a>00043     d_phase = <a class="code" href="classgr__fxpt.html#a8cf5f6942dd8db09072fb711d09b4820">gr_fxpt::float_to_fixed</a> (angle);
<a name="l00044"></a>00044   }
<a name="l00045"></a>00045 
<a name="l00046"></a><a class="code" href="classgr__fxpt__nco.html#a10dbfd4b18e7a071d0fc605f2865c0b5">00046</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a10dbfd4b18e7a071d0fc605f2865c0b5">adjust_phase</a> (<span class="keywordtype">float</span> delta_phase) {
<a name="l00047"></a>00047     d_phase += <a class="code" href="classgr__fxpt.html#a8cf5f6942dd8db09072fb711d09b4820">gr_fxpt::float_to_fixed</a> (delta_phase);
<a name="l00048"></a>00048   }
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   <span class="comment">// angle_rate is in radians / step</span>
<a name="l00051"></a><a class="code" href="classgr__fxpt__nco.html#ae0062d57b4282e923b616a8249c33ca8">00051</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#ae0062d57b4282e923b616a8249c33ca8">set_freq</a> (<span class="keywordtype">float</span> angle_rate){
<a name="l00052"></a>00052     d_phase_inc = <a class="code" href="classgr__fxpt.html#a8cf5f6942dd8db09072fb711d09b4820">gr_fxpt::float_to_fixed</a> (angle_rate);
<a name="l00053"></a>00053   }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055   <span class="comment">// angle_rate is a delta in radians / step</span>
<a name="l00056"></a><a class="code" href="classgr__fxpt__nco.html#ae0b360fc3c7c90594065c196d091a632">00056</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#ae0b360fc3c7c90594065c196d091a632">adjust_freq</a> (<span class="keywordtype">float</span> delta_angle_rate)
<a name="l00057"></a>00057   {
<a name="l00058"></a>00058     d_phase_inc += <a class="code" href="classgr__fxpt.html#a8cf5f6942dd8db09072fb711d09b4820">gr_fxpt::float_to_fixed</a> (delta_angle_rate);
<a name="l00059"></a>00059   }
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   <span class="comment">// increment current phase angle</span>
<a name="l00062"></a>00062 
<a name="l00063"></a><a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">00063</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> () 
<a name="l00064"></a>00064   { 
<a name="l00065"></a>00065     d_phase += d_phase_inc;
<a name="l00066"></a>00066   }
<a name="l00067"></a>00067 
<a name="l00068"></a><a class="code" href="classgr__fxpt__nco.html#a65fece87a9cbbbf70244408fa944bb9c">00068</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> (<span class="keywordtype">int</span> n)
<a name="l00069"></a>00069   {
<a name="l00070"></a>00070     d_phase += d_phase_inc * n;
<a name="l00071"></a>00071   }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073   <span class="comment">// units are radians / step</span>
<a name="l00074"></a><a class="code" href="classgr__fxpt__nco.html#a797e30fe6b0ef1fac0d994f7c6229c07">00074</a>   <span class="keywordtype">float</span> <a class="code" href="classgr__fxpt__nco.html#a797e30fe6b0ef1fac0d994f7c6229c07">get_phase</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classgr__fxpt.html#a4b89af0770b5c4751f52224976514c20">gr_fxpt::fixed_to_float</a> (d_phase); }
<a name="l00075"></a><a class="code" href="classgr__fxpt__nco.html#ada5afdcf3342cca4f08e84e9742eb4d2">00075</a>   <span class="keywordtype">float</span> <a class="code" href="classgr__fxpt__nco.html#ada5afdcf3342cca4f08e84e9742eb4d2">get_freq</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classgr__fxpt.html#a4b89af0770b5c4751f52224976514c20">gr_fxpt::fixed_to_float</a> (d_phase_inc); }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077   <span class="comment">// compute sin and cos for current phase angle</span>
<a name="l00078"></a><a class="code" href="classgr__fxpt__nco.html#ae3c392ca8bf4e7125ca26a34ce279097">00078</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#ae3c392ca8bf4e7125ca26a34ce279097">sincos</a> (<span class="keywordtype">float</span> *sinx, <span class="keywordtype">float</span> *cosx)<span class="keyword"> const</span>
<a name="l00079"></a>00079 <span class="keyword">  </span>{
<a name="l00080"></a>00080     *sinx = <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">gr_fxpt::sin</a> (d_phase);
<a name="l00081"></a>00081     *cosx = <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">gr_fxpt::cos</a> (d_phase);
<a name="l00082"></a>00082   }
<a name="l00083"></a>00083 
<a name="l00084"></a>00084   <span class="comment">// compute cos and sin for a block of phase angles</span>
<a name="l00085"></a><a class="code" href="classgr__fxpt__nco.html#a2db2f682d27fa1999c419c0609677e4d">00085</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#ae3c392ca8bf4e7125ca26a34ce279097">sincos</a> (<a class="code" href="gr__complex_8h.html#aec4bfe41433369afae9327f1b0bc9109">gr_complex</a> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00086"></a>00086   {
<a name="l00087"></a>00087     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00088"></a>00088       output[i]   = <a class="code" href="gr__complex_8h.html#aec4bfe41433369afae9327f1b0bc9109">gr_complex</a>(<a class="code" href="classgr__fxpt.html#a61861c9e4535e05a567a96a2551430a9">gr_fxpt::cos</a> (d_phase) * ampl, <a class="code" href="classgr__fxpt.html#a26312e3f31f6d7a6ae4810c05f30979a" title="Given a fixed point angle x, return float sine (x)">gr_fxpt::sin</a> (d_phase) * ampl);
<a name="l00089"></a>00089       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00090"></a>00090     }
<a name="l00091"></a>00091   }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093   <span class="comment">// compute sin for a block of phase angles</span>
<a name="l00094"></a><a class="code" href="classgr__fxpt__nco.html#a2e8d572d1dc2848b60c000750494c904">00094</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">sin</a> (<span class="keywordtype">float</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00095"></a>00095   {
<a name="l00096"></a>00096     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00097"></a>00097       output[i] = (float)(<a class="code" href="classgr__fxpt.html#a26312e3f31f6d7a6ae4810c05f30979a" title="Given a fixed point angle x, return float sine (x)">gr_fxpt::sin</a> (d_phase) * ampl);
<a name="l00098"></a>00098       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00099"></a>00099     }
<a name="l00100"></a>00100   }
<a name="l00101"></a>00101 
<a name="l00102"></a>00102   <span class="comment">// compute cos for a block of phase angles</span>
<a name="l00103"></a><a class="code" href="classgr__fxpt__nco.html#a311aa53513b5f3c2e636e00e1d1c2705">00103</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">cos</a> (<span class="keywordtype">float</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00104"></a>00104   {
<a name="l00105"></a>00105     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00106"></a>00106       output[i] = (float)(<a class="code" href="classgr__fxpt.html#a61861c9e4535e05a567a96a2551430a9">gr_fxpt::cos</a> (d_phase) * ampl);
<a name="l00107"></a>00107       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00108"></a>00108     }
<a name="l00109"></a>00109   }
<a name="l00110"></a>00110 
<a name="l00111"></a>00111   <span class="comment">// compute sin for a block of phase angles</span>
<a name="l00112"></a><a class="code" href="classgr__fxpt__nco.html#a102079e42d5b082b124ff3d5b8db15f6">00112</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">sin</a> (<span class="keywordtype">short</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00113"></a>00113   {
<a name="l00114"></a>00114     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00115"></a>00115       output[i] = (short)(<a class="code" href="classgr__fxpt.html#a26312e3f31f6d7a6ae4810c05f30979a" title="Given a fixed point angle x, return float sine (x)">gr_fxpt::sin</a> (d_phase) * ampl);
<a name="l00116"></a>00116       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00117"></a>00117     }
<a name="l00118"></a>00118   }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120   <span class="comment">// compute cos for a block of phase angles</span>
<a name="l00121"></a><a class="code" href="classgr__fxpt__nco.html#ab0ed3a49342ec91541924cb95c3bd303">00121</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">cos</a> (<span class="keywordtype">short</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00122"></a>00122   {
<a name="l00123"></a>00123     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00124"></a>00124       output[i] = (short)(<a class="code" href="classgr__fxpt.html#a61861c9e4535e05a567a96a2551430a9">gr_fxpt::cos</a> (d_phase) * ampl);
<a name="l00125"></a>00125       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00126"></a>00126     }
<a name="l00127"></a>00127   }
<a name="l00128"></a>00128 
<a name="l00129"></a>00129   <span class="comment">// compute sin for a block of phase angles</span>
<a name="l00130"></a><a class="code" href="classgr__fxpt__nco.html#a1b0f0e5b6548be6ca44d0f09800211c9">00130</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">sin</a> (<span class="keywordtype">int</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00131"></a>00131   {
<a name="l00132"></a>00132     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00133"></a>00133       output[i] = (int)(<a class="code" href="classgr__fxpt.html#a26312e3f31f6d7a6ae4810c05f30979a" title="Given a fixed point angle x, return float sine (x)">gr_fxpt::sin</a> (d_phase) * ampl);
<a name="l00134"></a>00134       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00135"></a>00135     }
<a name="l00136"></a>00136   }
<a name="l00137"></a>00137 
<a name="l00138"></a>00138   <span class="comment">// compute cos for a block of phase angles</span>
<a name="l00139"></a><a class="code" href="classgr__fxpt__nco.html#ab76eb27d0cc0d59358dfa90bff46e51b">00139</a>   <span class="keywordtype">void</span> <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">cos</a> (<span class="keywordtype">int</span> *output, <span class="keywordtype">int</span> noutput_items, <span class="keywordtype">double</span> ampl=1.0)
<a name="l00140"></a>00140   {
<a name="l00141"></a>00141     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; noutput_items; i++){
<a name="l00142"></a>00142       output[i] = (int)(<a class="code" href="classgr__fxpt.html#a61861c9e4535e05a567a96a2551430a9">gr_fxpt::cos</a> (d_phase) * ampl);
<a name="l00143"></a>00143       <a class="code" href="classgr__fxpt__nco.html#a3fb5e466e56b70bd2d40f7a911c17e89">step</a> ();
<a name="l00144"></a>00144     }
<a name="l00145"></a>00145   }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147   <span class="comment">// compute cos or sin for current phase angle</span>
<a name="l00148"></a><a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">00148</a>   <span class="keywordtype">float</span> <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">cos</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classgr__fxpt__nco.html#a8aaf462add026c1299311134490aedb1">gr_fxpt::cos</a> (d_phase); }
<a name="l00149"></a><a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">00149</a>   <span class="keywordtype">float</span> <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">sin</a> ()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classgr__fxpt__nco.html#a576159c8fceb8464aa41405fc9630b1c">gr_fxpt::sin</a> (d_phase); }
<a name="l00150"></a>00150 };
<a name="l00151"></a>00151 
<a name="l00152"></a>00152 <span class="preprocessor">#endif </span><span class="comment">/* INCLUDED_GR_FXPT_NCO_H */</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="gr__fxpt__nco_8h.html">gr_fxpt_nco.h</a>      </li>
      <li class="footer">Generated on Thu Feb 17 2011 for GNU Radio 3.2.2 C++ API by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li>
    </ul>
  </div>

</body>
</html>