<?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>adsynt</title> <link rel="stylesheet" href="csound.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /> <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="adsyn.html" title="adsyn" /> <link rel="next" href="adsynt2.html" title="adsynt2" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">adsynt</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="adsyn.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="adsynt2.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="adsynt"> <a id="adsynt"></a> <div class="titlepage"></div> <a id="IndexAdsynt" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">adsynt</span> </h2> <p>adsynt — Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic. </p> </div> <div class="refsect1" title="Description"> <a id="id2742225"></a> <h2>Description</h2> <p> Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic. </p> </div> <div class="refsect1" title="Syntax"> <a id="id2742239"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>adsynt</strong></span> kamp, kcps, iwfn, ifreqfn, iampfn, icnt [, iphs]</pre> </div> <div class="refsect1" title="Initialization"> <a id="id2742259"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>iwfn</em></span> -- table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality. </p> <p> <span class="emphasis"><em>ifreqfn</em></span> -- table containing frequency values for each partial. <span class="emphasis"><em>ifreqfn</em></span> may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with <span class="emphasis"><em>tablew</em></span>. Frequencies must be relative to <span class="emphasis"><em>kcps</em></span>. Size must be at least <span class="emphasis"><em>icnt</em></span>. </p> <p> <span class="emphasis"><em>iampfn</em></span> -- table containing amplitude values for each partial. <span class="emphasis"><em>iampfn</em></span> may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with <span class="emphasis"><em>tablew</em></span>. Amplitudes must be relative to <span class="emphasis"><em>kamp</em></span>. Size must be at least <span class="emphasis"><em>icnt</em></span>. </p> <p> <span class="emphasis"><em>icnt</em></span> -- number of partials to be generated </p> <p> <span class="emphasis"><em>iphs</em></span> -- initial phase of each oscillator, if <span class="emphasis"><em>iphs</em></span> = -1, initialization is skipped. If <span class="emphasis"><em>iphs</em></span> > 1, all phases will be initialized with a random value. </p> </div> <div class="refsect1" title="Performance"> <a id="id2743255"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kamp</em></span> -- amplitude of note </p> <p> <span class="emphasis"><em>kcps</em></span> -- base frequency of note. Partial frequencies will be relative to <span class="emphasis"><em>kcps</em></span>. </p> <p> Frequency and amplitude of each partial is given in the two tables provided. The purpose of this opcode is to have an instrument generate synthesis parameters at k-rate and write them to global parameter tables with the <span class="emphasis"><em>tablew</em></span> opcode. </p> </div> <div class="refsect1" title="Examples"> <a id="id2743294"></a> <h2>Examples</h2> <p> Here is an example of the adsynt opcode. It uses the file <a class="ulink" href="examples/adsynt.csd" target="_top"><em class="citetitle">adsynt.csd</em></a>. These two instruments perform additive synthesis. The output of each sounds like a Tibetan bowl. The first one is static, as parameters are only generated at init-time. In the second one, parameters are continuously changed. </p> <div class="example"> <a id="id2743317"></a> <p class="title"> <b>Example 38. Example of the adsynt opcode.</b> </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">;;;RT audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o adsynt.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="comment">; Generate a sinewave table.</span> giwave <span class="ohdr">ftgen</span> 1, 0, 1024, 10, 1 <span class="comment">; Generate two empty tables for adsynt.</span> gifrqs <span class="ohdr">ftgen</span> 2, 0, 32, 7, 0, 32, 0 <span class="comment">; A table for freqency and amp parameters.</span> giamps <span class="ohdr">ftgen</span> 3, 0, 32, 7, 0, 32, 0 <span class="comment">; Generates parameters at init time</span> <span class="oblock">instr</span> 1 <span class="comment">; Generate 10 voices.</span> icnt <span class="op">=</span> 10 <span class="comment">; Init loop index.</span> index <span class="op">=</span> 0 <span class="comment">; Loop only executed at init time.</span> <span class="olabel">loop</span><span class="op">:</span> <span class="comment">; Define non-harmonic partials.</span> ifreq <span class="opc">pow</span> index <span class="op">+</span> 1, 1.5 <span class="comment">; Define amplitudes.</span> iamp <span class="op">=</span> 1 <span class="op">/</span> (index<span class="op">+</span>1) <span class="comment">; Write to tables.</span> <span class="opc">tableiw</span> ifreq, index, gifrqs <span class="comment">; Used by adsynt.</span> <span class="opc">tableiw</span> iamp, index, giamps index <span class="op">=</span> index <span class="op">+</span> 1 <span class="comment">; Do loop/</span> <span class="octrl">if</span> (index <span class="op"><</span> icnt) <span class="octrl">igoto</span> <span class="olabel">loop</span> asig <span class="opc">adsynt</span> 0.3, 150, giwave, gifrqs, giamps, icnt <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="comment">; Generates parameters every k-cycle.</span> <span class="oblock">instr</span> 2 <span class="comment">; Generate 10 voices.</span> icnt <span class="op">=</span> 10 <span class="comment">; Reset loop index.</span> kindex <span class="op">=</span> 0 <span class="comment">; Loop executed every k-cycle.</span> <span class="olabel">loop</span><span class="op">:</span> <span class="comment">; Generate lfo for frequencies.</span> kspeed <span class="opc">pow</span> kindex <span class="op">+</span> 1, 1.6 <span class="comment">; Individual phase for each voice.</span> kphas <span class="opc">phasorbnk</span> kspeed <span class="op">*</span> 0.7, kindex, icnt klfo <span class="opc">table</span> kphas, giwave, 1 <span class="comment">; Arbitrary parameter twiddling...</span> kdepth <span class="opc">pow</span> 1.4, kindex kfreq <span class="opc">pow</span> kindex <span class="op">+</span> 1, 1.5 kfreq <span class="op">=</span> kfreq <span class="op">+</span> klfo<span class="op">*</span>0.006<span class="op">*</span>kdepth <span class="comment">; Write freqs to table for adsynt.</span> <span class="opc">tablew</span> kfreq, kindex, gifrqs <span class="comment">; Generate lfo for amplitudes.</span> kspeed <span class="opc">pow</span> kindex <span class="op">+</span> 1, 0.8 <span class="comment">; Individual phase for each voice.</span> kphas <span class="opc">phasorbnk</span> kspeed<span class="op">*</span>0.13, kindex, icnt, 2 klfo <span class="opc">table</span> kphas, giwave, 1 <span class="comment">; Arbitrary parameter twiddling...</span> kamp <span class="opc">pow</span> 1 <span class="op">/</span> (kindex <span class="op">+</span> 1), 0.4 kamp <span class="op">=</span> kamp <span class="op">*</span> (0.3<span class="op">+</span>0.35<span class="op">*</span>(klfo<span class="op">+</span>1)) <span class="comment">; Write amps to table for adsynt.</span> <span class="opc">tablew</span> kamp, kindex, giamps kindex <span class="op">=</span> kindex <span class="op">+</span> 1 <span class="comment">; Do loop.</span> <span class="octrl">if</span> (kindex <span class="op"><</span> icnt) <span class="octrl">kgoto</span> <span class="olabel">loop</span> asig <span class="opc">adsynt</span> 0.25, 150, giwave, gifrqs, giamps, icnt <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Play Instrument #1 for 2.5 seconds.</span> <span class="stamnt">i</span> 1 0 2.5 <span class="comment">; Play Instrument #2 for 2.5 seconds.</span> <span class="stamnt">i</span> 2 3 2.5 <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="id2743356"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Peter Neubäcker</td> </tr> <tr> <td>Munich, Germany</td> </tr> <tr> <td>August, 1999</td> </tr> </table> <p> </p> <p>New in Csound version 3.58</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="adsyn.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="adsynt2.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">adsyn </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> adsynt2</td> </tr> </table> </div> </body> </html>