<?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>GEN32</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="ScoregensTop.html" title="Score Statements and GEN Routines" /> <link rel="prev" href="GEN31.html" title="GEN31" /> <link rel="next" href="GEN33.html" title="GEN33" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">GEN32</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="GEN31.html">Prev</a> </td> <th width="60%" align="center">Score Statements and GEN Routines</th> <td width="20%" align="right"> <a accesskey="n" href="GEN33.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="GEN32"> <a id="GEN32"></a> <div class="titlepage"></div> <a id="IndexGEN32" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">GEN32</span> </h2> <p>GEN32 — Mixes any waveform, resampled with either FFT or linear interpolation. </p> </div> <div class="refsect1" title="Description"> <a id="id3743466"></a> <h2>Description</h2> <p> This routine is similar to <a class="link" href="GEN31.html" title="GEN31"><em class="citetitle">GEN31</em></a>, but allows specifying source ftable for each partial. Tables can be resampled either with FFT, or linear interpolation. </p> </div> <div class="refsect1" title="Syntax"> <a id="id3743494"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 32 srca pna stra phsa srcb pnb strb phsb ...</pre> </div> <div class="refsect1" title="Performance"> <a id="id3743512"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>srca, srcb</em></span> -- source table number. A negative value can be used to read the table with linear interpolation (by default, the source waveform is transposed and phase shifted using FFT); this is less accurate, but faster, and allows non-integer and negative partial numbers. </p> <p> <span class="emphasis"><em>pna, pnb, ...</em></span> -- partial number, must be a positive integer if source table number is positive (i.e. resample with FFT). </p> <p> <span class="emphasis"><em>stra, strb, ...</em></span> -- amplitude scale </p> <p> <span class="emphasis"><em>phsa, phsb, ...</em></span> -- start phase (0 to 1) </p> </div> <div class="refsect1" title="Examples"> <a id="id3743553"></a> <h2>Examples</h2> <p> </p> <div class="informalexample"> <pre class="programlisting"> itmp <span class="opc">ftgen</span> 1, 0, 16384, 7, 1, 16384, <span class="op">-</span>1 <span class="comment">; sawtooth</span> itmp <span class="opc">ftgen</span> 2, 0, 8192, 10, 1 <span class="comment">; sine</span> <span class="comment">; mix tables</span> itmp <span class="opc">ftgen</span> 5, 0, 4096, <span class="op">-</span>32, <span class="op">-</span>2, 1.5, 1.0, 0.25, 1, 2, 0.5, 0, \ 1, 3, <span class="op">-</span>0.25, 0.5 <span class="comment">; window</span> itmp <span class="opc">ftgen</span> 6, 0, 16384, 20, 3, 1 <span class="comment">; generate band-limited waveforms</span> inote <span class="op">=</span> 0 <span class="olabel">loop0:</span> icps <span class="op">=</span> 440 <span class="op">*</span> <span class="opc">exp</span>(<span class="opc">log</span>(2) <span class="op">*</span> (inote <span class="op">-</span> 69) <span class="op">/</span> 12) <span class="comment">; one table for</span> inumh <span class="op">=</span> <span class="ohdr">sr</span> <span class="op">/</span> (2 <span class="op">*</span> icps) <span class="comment">; each MIDI note number</span> ift <span class="op">=</span> <span class="opc">int</span>(inote <span class="op">+</span> 256.5) itmp <span class="opc">ftgen</span> ift, 0, 4096, <span class="op">-</span>30, 5, 1, inumh inote <span class="op">=</span> inote <span class="op">+</span> 1 <span class="octrl">if</span> (inote <span class="op"><</span> 127.5) <span class="octrl">igoto</span> <span class="olabel">loop0</span> <span class="oblock">instr</span> 1 kcps <span class="opc">expon</span> 20, p3, 16000 kft <span class="op">=</span> <span class="opc">int</span>(256.5 <span class="op">+</span> 69 <span class="op">+</span> 12 <span class="op">*</span> <span class="opc">log</span>(kcps <span class="op">/</span> 440) <span class="op">/</span> <span class="opc">log</span>(2)) kft <span class="op">=</span> (kft <span class="op">></span> 383 <span class="op">?</span> 383 <span class="op">:</span> kft) a1 <span class="opc">phasor</span> kcps a1 <span class="opc">tableikt</span> a1, kft, 1, 0, 1 <span class="opc">out</span> a1 <span class="op">*</span> 10000 <span class="oblock">endin</span> <span class="oblock">instr</span> 2 kcps <span class="opc">expon</span> 20, p3, 16000 kft <span class="op">=</span> <span class="opc">int</span>(256.5 <span class="op">+</span> 69 <span class="op">+</span> 12 <span class="op">*</span> <span class="opc">log</span>(kcps <span class="op">/</span> 440) <span class="op">/</span> <span class="opc">log</span>(2)) kft <span class="op">=</span> (kft <span class="op">></span> 383 <span class="op">?</span> 383 <span class="op">:</span> kft) kgdur <span class="opc">limit</span> 10 <span class="op">/</span> kcps, 0.1, 1 a1 <span class="opc">grain2</span> kcps, 0.02, kgdur, 30, kft, 6, <span class="op">-</span>0.5 <span class="opc">out</span> a1 <span class="op">*</span> 2000 <span class="oblock">endin</span> ---------- score: ---------- <span class="stamnt">t</span> 0 60 <span class="stamnt">i</span> 1 0 10 <span class="stamnt">i</span> 2 12 10 <span class="stamnt">e</span></pre> </div> <p> </p> </div> <div class="refsect1" title="Credits"> <a id="id3744828"></a> <h2>Credits</h2> <p>Author: Rasmus Ekman</p> <p>Programmer: Istvan Varga</p> <p>New in version 4.17</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="GEN31.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="ScoregensTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="GEN33.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">GEN31 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> GEN33</td> </tr> </table> </div> </body> </html>