<!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"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.13"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>aubio: examples/aubiopitch.c</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); </script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td id="projectalign" style="padding-left: 0.5em;"> <div id="projectname">aubio  <span id="projectnumber">0.4.2~alpha</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.13 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); </script> <div id="main-nav"></div> </div><!-- top --> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div class="header"> <div class="headertitle"> <div class="title">examples/aubiopitch.c</div> </div> </div><!--header--> <div class="contents"> <div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org></span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"> This file is part of aubio.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"> aubio is free software: you can redistribute it and/or modify</span></div><div class="line"><span class="comment"> it under the terms of the GNU General Public License as published by</span></div><div class="line"><span class="comment"> the Free Software Foundation, either version 3 of the License, or</span></div><div class="line"><span class="comment"> (at your option) any later version.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"> aubio is distributed in the hope that it will be useful,</span></div><div class="line"><span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div><div class="line"><span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span></div><div class="line"><span class="comment"> GNU General Public License for more details.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment"> You should have received a copy of the GNU General Public License</span></div><div class="line"><span class="comment"> along with aubio. If not, see <http://www.gnu.org/licenses/>.</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">*/</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include "utils.h"</span></div><div class="line"><span class="preprocessor">#define PROG_HAS_PITCH 1</span></div><div class="line"><span class="preprocessor">#define PROG_HAS_OUTPUT 1</span></div><div class="line"><span class="preprocessor">#define PROG_HAS_JACK 1</span></div><div class="line"><span class="preprocessor">#include "parse_args.h"</span></div><div class="line"></div><div class="line"><a class="code" href="pitch_8h.html#af76b14582e2b766e6b325038fe6426a0">aubio_pitch_t</a> *o;</div><div class="line"><a class="code" href="wavetable_8h.html#abbf3d07fc6bfec0ababa1e36fa4d2953">aubio_wavetable_t</a> *wavetable;</div><div class="line"><a name="_a0"></a><a class="code" href="structfvec__t.html">fvec_t</a> *pitch;</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> process_block(<a class="code" href="structfvec__t.html">fvec_t</a> * ibuf, <a class="code" href="structfvec__t.html">fvec_t</a> * obuf)</div><div class="line">{</div><div class="line"> <a class="code" href="types_8h.html#a5d7119468d78a1dc35cf76d0adfb1436">smpl_t</a> freq;</div><div class="line"> <a name="a1"></a><a class="code" href="pitch_8h.html#aa813fd341d5af4c0dc672e319b0f0195">aubio_pitch_do</a> (o, ibuf, pitch);</div><div class="line"> <span class="keywordflow">if</span> ( !usejack && ! sink_uri ) <span class="keywordflow">return</span>;</div><div class="line"> <a name="a2"></a><a class="code" href="fvec_8h.html#aab4522ad4c26322858ecce0e7aad08ea">fvec_zeros</a>(obuf);</div><div class="line"> freq = <a name="a3"></a><a class="code" href="fvec_8h.html#ac4adbfa24102a9611e188df7b3da05d0">fvec_get_sample</a>(pitch, 0);</div><div class="line"> <a name="a4"></a><a class="code" href="wavetable_8h.html#ad2a1038f6748551e688fbe328ab14f90">aubio_wavetable_set_amp</a> ( wavetable, <a name="a5"></a><a class="code" href="musicutils_8h.html#a73f016353e3b67941d9d83938d7119de">aubio_level_lin</a> (ibuf) );</div><div class="line"> <a name="a6"></a><a class="code" href="wavetable_8h.html#a1f51931af1a13db4667173aca645d05d">aubio_wavetable_set_freq</a> ( wavetable, freq );</div><div class="line"> <span class="keywordflow">if</span> (mix_input)</div><div class="line"> <a name="a7"></a><a class="code" href="wavetable_8h.html#acb766dead872e20b256117a03a0a54ce">aubio_wavetable_do</a> (wavetable, ibuf, obuf);</div><div class="line"> <span class="keywordflow">else</span></div><div class="line"> <a class="code" href="wavetable_8h.html#acb766dead872e20b256117a03a0a54ce">aubio_wavetable_do</a> (wavetable, obuf, obuf);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> process_print (<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line"> <a class="code" href="types_8h.html#a5d7119468d78a1dc35cf76d0adfb1436">smpl_t</a> pitch_found = <a class="code" href="fvec_8h.html#ac4adbfa24102a9611e188df7b3da05d0">fvec_get_sample</a>(pitch, 0);</div><div class="line"> outmsg(<span class="stringliteral">"%f %f\n"</span>,(blocks)</div><div class="line"> *hop_size/(<span class="keywordtype">float</span>)samplerate, pitch_found);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {</div><div class="line"></div><div class="line"> buffer_size = 2048;</div><div class="line"></div><div class="line"> examples_common_init(argc,argv);</div><div class="line"></div><div class="line"> verbmsg (<span class="stringliteral">"using source: %s at %dHz\n"</span>, source_uri, samplerate);</div><div class="line"> verbmsg (<span class="stringliteral">"pitch method: %s, "</span>, pitch_method);</div><div class="line"> verbmsg (<span class="stringliteral">"pitch unit: %s, "</span>, pitch_unit);</div><div class="line"> verbmsg (<span class="stringliteral">"buffer_size: %d, "</span>, buffer_size);</div><div class="line"> verbmsg (<span class="stringliteral">"hop_size: %d, "</span>, hop_size);</div><div class="line"> verbmsg (<span class="stringliteral">"tolerance: %f\n"</span>, pitch_tolerance);</div><div class="line"></div><div class="line"> o = <a name="a8"></a><a class="code" href="pitch_8h.html#a962561ea270e0308ed26ac9bab554550">new_aubio_pitch</a> (pitch_method, buffer_size, hop_size, samplerate);</div><div class="line"> <span class="keywordflow">if</span> (pitch_tolerance != 0.)</div><div class="line"> <a name="a9"></a><a class="code" href="pitch_8h.html#ac7f0342944d7fde3cd509021069ee74d">aubio_pitch_set_tolerance</a> (o, pitch_tolerance);</div><div class="line"> <span class="keywordflow">if</span> (silence_threshold != -90.)</div><div class="line"> <a name="a10"></a><a class="code" href="pitch_8h.html#afc207da0622a9cedb601a3b84b3fd543">aubio_pitch_set_silence</a> (o, silence_threshold);</div><div class="line"> <span class="keywordflow">if</span> (pitch_unit != NULL)</div><div class="line"> <a name="a11"></a><a class="code" href="pitch_8h.html#aa4fa64844cbcedd81127643e0093103c">aubio_pitch_set_unit</a> (o, pitch_unit);</div><div class="line"></div><div class="line"> pitch = <a name="a12"></a><a class="code" href="fvec_8h.html#aa9bc0906651523429a4ebf7b4342fe73">new_fvec</a> (1);</div><div class="line"></div><div class="line"> wavetable = <a name="a13"></a><a class="code" href="wavetable_8h.html#ae1433850799b37ef1c13772b8a5d332b">new_aubio_wavetable</a> (samplerate, hop_size);</div><div class="line"> <a name="a14"></a><a class="code" href="wavetable_8h.html#aeb76a5d89b91b509b297ea480a1b7b2a">aubio_wavetable_play</a> ( wavetable );</div><div class="line"></div><div class="line"> examples_common_process((aubio_process_func_t)process_block,process_print);</div><div class="line"></div><div class="line"> <a name="a15"></a><a class="code" href="pitch_8h.html#a23f6b16eabb9bff3c4ee5876af69f832">del_aubio_pitch</a> (o);</div><div class="line"> <a name="a16"></a><a class="code" href="wavetable_8h.html#aef974c1cee018f29d8b61c12a430b63a">del_aubio_wavetable</a> (wavetable);</div><div class="line"> <a name="a17"></a><a class="code" href="fvec_8h.html#a86fad6d27aad91c910d1b48195922cb9">del_fvec</a> (pitch);</div><div class="line"></div><div class="line"> examples_common_del();</div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.13 </small></address> </body> </html>