<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!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/html; charset=UTF-8" /> <title>harmon2</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="harmon.html" title="harmon" /> <link rel="next" href="hilbert.html" title="hilbert" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">harmon2</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="harmon.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="hilbert.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="harmon2"> <a id="harmon2"></a> <div class="titlepage"></div> <a id="IndexHarmon2" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">harmon2</span> </h2> <p>harmon2 — Analyze an audio input and generate harmonizing voices in synchrony with formants preserved. </p> </div> <div class="refsect1" title="Description"> <a id="idp25767728"></a> <h2>Description</h2> <p> Generate harmonizing voices with formants preserved. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp25768392"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>harmon2</strong></span> asig, koct, kfrq1, kfrq2, icpsmode, ilowest[, ipolarity]</pre> <pre class="synopsis">ares <span class="command"><strong>harmon3</strong></span> asig, koct, kfrq1, \ kfrq2, kfrq3, icpsmode, ilowest[, ipolarity]</pre> <pre class="synopsis">ares <span class="command"><strong>harmon4</strong></span> asig, koct, kfrq1, \ kfrq2, kfrq3, kfrq4, icpsmode, ilowest[, ipolarity]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp25780632"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>icpsmode</em></span> -- interpreting mode for the generating frequency inputs <span class="emphasis"><em>kfrq1</em></span>, <span class="emphasis"><em>kfrq2</em></span>, <span class="emphasis"><em>kfrq3</em></span> and <span class="emphasis"><em>kfrq4</em></span>: 0: input values are ratios w.r.t. the cps equivalent of <span class="emphasis"><em>koct</em></span>. 1: input values are the actual requested frequencies in cps. </p> <p> <span class="emphasis"><em>ilowest</em></span> -- lowest value of the <span class="emphasis"><em>koct</em></span> input for which harmonizing voices will be generated. </p> <p> <span class="emphasis"><em>ipolarity</em></span> -- polarity of <span class="emphasis"><em>asig</em></span> input, 1 = positive glottal pulses, 0 = negative. Default is 1. </p> </div> <div class="refsect1" title="Performance"> <a id="idp25820824"></a> <h2>Performance</h2> <p> <span class="command"><strong>Harmon2</strong></span>, <span class="command"><strong>harmon3</strong></span> and <span class="command"><strong>harmon4</strong></span> are high-performance harmonizers, able to provide up to four pitch-shifted copies of the input <span class="emphasis"><em>asig</em></span> with spectral formants preserved. The pitch-shifting algorithm requires an accurate running estimate (<span class="emphasis"><em>koct</em></span>, in decimal oct units) of the pitched content of <span class="emphasis"><em>asig</em></span>, normally gained from an independent pitch tracker such as <span class="emphasis"><em>specptrk</em></span>. The algorithm then isolates the most recent full pulse within <span class="emphasis"><em>asig</em></span>, and uses this to generate the other voices at their required pulse rates. </p> <p> If the frequency (or ratio) presented to <span class="emphasis"><em>kfrq1</em></span>, <span class="emphasis"><em>kfrq2</em></span>, <span class="emphasis"><em>kfrq3</em></span> or <span class="emphasis"><em>kfrq4</em></span> is zero, then no signal is generated for that voice. If any of them is non-zero, but the <span class="emphasis"><em>koct</em></span> input is below the value <span class="emphasis"><em>ilowest</em></span>, then that voice will output a direct copy of the input <span class="emphasis"><em>asig.</em></span> As a consequence, the data arriving at the k-rate inputs can variously cause the generated voices to be turned on or off, to pass a direct copy of a non-voiced fricative source, or to harmonize the source according to some constructed algorithm. The transition from one mode to another is cross-faded, giving seemless alternating between voiced (harmonized) and non-voiced fricatives during spoken or sung input. </p> <p> <span class="emphasis"><em>harmon2</em></span>, <span class="emphasis"><em>harmon3</em></span>, <span class="emphasis"><em>harmon4</em></span> are especially matched to the output of <span class="emphasis"><em>specptrk</em></span>. The latter generates pitch data in decimal octave format; it also emits its base value if no pitch is identified (as in fricative noise) and emits zero if the energy falls below a threshold, so that <span class="emphasis"><em>harmon2</em></span>, <span class="emphasis"><em>harmon3</em></span>, <span class="emphasis"><em>harmon4</em></span> can be set to pass the direct signal in both cases. Of course, any other form of pitch estimation could also be used. Since pitch trackers usually incur a slight delay for accurate estimation (for <span class="emphasis"><em>specptrk</em></span> the delay is printed by the <span class="emphasis"><em>spectrum</em></span> unit), it is normal to delay the audio signal by the same amount so that <span class="emphasis"><em>harmon2</em></span>, <span class="emphasis"><em>harmon3</em></span>, <span class="emphasis"><em>harmon4</em></span> can work from a fully concurrent estimate. </p> </div> <div class="refsect1" title="Examples"> <a id="idp25829936"></a> <h2>Examples</h2> <p> Here is an example of the harmon2 opcode. It uses the file <a class="ulink" href="examples/harmon.csd" target="_top"><em class="citetitle">harmon.csd</em></a>. </p> <div class="example"> <a id="idp25830904"></a> <p class="title"> <strong>Example 335. Example of the harmon2 opcode.</strong> </p> <div class="example-contents"> <pre class="programlisting"> a1,a2 <span class="opc">ins</span> <span class="comment">; get mic input</span> w1 <span class="opc">spectrum</span> a1, .02, 7, 24, 12, 1, 3 <span class="comment">; and examine it</span> koct,kamp <span class="opc">specptrk</span> w1, 1, 6.5, 9.5, 7.5, 10, 7, .7, 0, 3, 1 a3 <span class="opc">delay</span> a1, .065 <span class="comment">; allow for ptrk delay</span> a4 <span class="opc">harmon2</span> a3, koct, 1.25, 0.75, 0, 6.9 <span class="comment">; output a fixed 6-4 harmony</span> <span class="opc">outs</span> a3, a4 <span class="comment">; as well as the original</span></pre> </div> </div> <p><br class="example-break" /> </p> <p> Here is a complete example of the harmon3 opcode. It uses the file <a class="ulink" href="examples/harmon3.csd" target="_top"><em class="citetitle">harmon3.csd</em></a>. </p> <div class="example"> <a id="idp25836408"></a> <p class="title"> <strong>Example 336. Example of the harmon3 opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if realtime audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o harmon3.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 ilow <span class="op">=</span> p4 <span class="comment">;lowest value to harmonize </span> aout <span class="opc">diskin2</span> "fox.wav", 1, 0, 1 koct, kamp <span class="opc">pitch</span> aout, .01, 6, 10, 10 <span class="comment">;track pitch</span> asig <span class="opc">harmon3</span> aout, koct, .9, 1.5, 0.7, 0, ilow <span class="opc">outs</span> (asig <span class="op">+</span> aout)<span class="op">*</span>.4, (asig <span class="op">+</span> aout)<span class="op">*</span>.4 <span class="comment">;mix dry&wet signal</span> <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span>1 0 2.7 8.8 <span class="stamnt">i</span>1 3 2.7 8.2 <span class="stamnt">i</span>1 6 2.7 7.0 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="Credits"> <a id="idp25838688"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Barry L. Vercoe</td> </tr> <tr> <td>M.I.T., Cambridge, Mass</td> </tr> <tr> <td>2006</td> </tr> </table> <p> </p> <p>New in version 5.04</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="harmon.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="hilbert.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">harmon </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> hilbert</td> </tr> </table> </div> </body> </html>