<!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/aubiotrack.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/aubiotrack.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_TEMPO 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="tempo_8h.html#a4d9ae24f5a1ffe740169611a298e991b">aubio_tempo_t</a> * tempo;</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> * tempo_out;</div><div class="line"><a class="code" href="types_8h.html#a5d7119468d78a1dc35cf76d0adfb1436">smpl_t</a> is_beat = 0;</div><div class="line"><a class="code" href="types_8h.html#a12a1e9b3ce141648783a82445d02b58d">uint_t</a> is_silence = 0.;</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"> <a name="a1"></a><a class="code" href="tempo_8h.html#ae622b5d24b701fd62a3f6a69e42d7f8d">aubio_tempo_do</a> (tempo, ibuf, tempo_out);</div><div class="line"> is_beat = <a name="a2"></a><a class="code" href="fvec_8h.html#ac4adbfa24102a9611e188df7b3da05d0">fvec_get_sample</a> (tempo_out, 0);</div><div class="line"> <span class="keywordflow">if</span> (silence_threshold != -90.)</div><div class="line"> is_silence = <a name="a3"></a><a class="code" href="musicutils_8h.html#a4277e50cf32d171f0efb84ed01a17dc0">aubio_silence_detection</a>(ibuf, silence_threshold);</div><div class="line"> <span class="keywordflow">if</span> ( !usejack && ! sink_uri ) <span class="keywordflow">return</span>;</div><div class="line"> <a name="a4"></a><a class="code" href="fvec_8h.html#aab4522ad4c26322858ecce0e7aad08ea">fvec_zeros</a> (obuf);</div><div class="line"> <span class="keywordflow">if</span> ( is_beat && !is_silence ) {</div><div class="line"> <a name="a5"></a><a class="code" href="wavetable_8h.html#aeb76a5d89b91b509b297ea480a1b7b2a">aubio_wavetable_play</a> ( wavetable );</div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <a name="a6"></a><a class="code" href="wavetable_8h.html#ab39769ce70db186dd340cce48a20431f">aubio_wavetable_stop</a> ( wavetable );</div><div class="line"> }</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"> <span class="keywordflow">if</span> ( is_beat && !is_silence ) {</div><div class="line"> outmsg(<span class="stringliteral">"%f\n"</span>, <a name="a8"></a><a class="code" href="tempo_8h.html#a5c43eae0bbaa6b05c11e7f70cde6fb08">aubio_tempo_get_last_s</a>(tempo) );</div><div class="line"> }</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"> <span class="comment">// override general settings from utils.c</span></div><div class="line"> buffer_size = 1024;</div><div class="line"> hop_size = 512;</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"></div><div class="line"> verbmsg (<span class="stringliteral">"tempo method: %s, "</span>, tempo_method);</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">"threshold: %f\n"</span>, onset_threshold);</div><div class="line"></div><div class="line"> tempo_out = <a name="a9"></a><a class="code" href="fvec_8h.html#aa9bc0906651523429a4ebf7b4342fe73">new_fvec</a>(2);</div><div class="line"> tempo = <a name="a10"></a><a class="code" href="tempo_8h.html#aaa49f5d6554904a452d031775f385521">new_aubio_tempo</a>(tempo_method, buffer_size, hop_size, samplerate);</div><div class="line"> <span class="comment">// set silence threshold very low to output beats even during silence</span></div><div class="line"> <span class="comment">// aubio_tempo_set_silence(tempo, -1000.);</span></div><div class="line"> <span class="keywordflow">if</span> (onset_threshold != 0.) <a name="a11"></a><a class="code" href="tempo_8h.html#a8ec34621caf30fed304cdf15221ca2d2">aubio_tempo_set_threshold</a> (tempo, onset_threshold);</div><div class="line"></div><div class="line"> wavetable = <a name="a12"></a><a class="code" href="wavetable_8h.html#ae1433850799b37ef1c13772b8a5d332b">new_aubio_wavetable</a> (samplerate, hop_size);</div><div class="line"> <a name="a13"></a><a class="code" href="wavetable_8h.html#a1f51931af1a13db4667173aca645d05d">aubio_wavetable_set_freq</a> ( wavetable, 2450.);</div><div class="line"> <span class="comment">//aubio_sampler_load (sampler, "/archives/sounds/woodblock.aiff");</span></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="a14"></a><a class="code" href="tempo_8h.html#a427274677aae195a93753e56d70b5f19">del_aubio_tempo</a>(tempo);</div><div class="line"> <a name="a15"></a><a class="code" href="wavetable_8h.html#aef974c1cee018f29d8b61c12a430b63a">del_aubio_wavetable</a> (wavetable);</div><div class="line"> <a name="a16"></a><a class="code" href="fvec_8h.html#a86fad6d27aad91c910d1b48195922cb9">del_fvec</a>(tempo_out);</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>