Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 164

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>GENwave</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="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GENfarey.html" title="GENfarey" />
    <link rel="next" href="DeprecatedTop.html" title="Deprecated Orchestra Opcodes and GEN Routines" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GENwave</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GENfarey.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="DeprecatedTop.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="GENwave">
      <a id="GENwave"></a>
      <div class="titlepage"></div>
      <a id="IndexGENwave" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GENwave</span>
        </h2>
        <p>"wave" — 
      Generates a compactly supported wavelet function.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp78737040"></a>
        <h2>Description</h2>
        <p>
      Creates a compactly supported wavelet, scaling function or wavelet
      packet. The output function is obtained by deconvolution of
      corresponding mirror filter impulse response. This procedure is
      applied in an iterative fashion. 
    </p>
        <p>
      The filter bank used in classic discrete wavelet transform grows
      only towards low frequencies. Meanwhile wavelet packet transform
      introduces any possible direction of tree's growth. The sequence
      of mirror filters used in deconvolution is determined by binary
      form of seq value. "0" corresponds to low-pass filter and "1" to
      high-pass. 
    </p>
        <p>
      The number of iteration steps is determined by filter's length
      and size of function table. I.e. for filter length 8 and table
      size 256 there are log2(256/8) = 5 iterations available. 
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp78772976"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size "wave" fnsf seq rescale</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp78773912"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>size</em></span> -- number of points in the table. Must
      be a power of 2 or power-of-2 plus 1 (see <a class="link" href="f.html" title="f Statement (or Function Table Statement)"><em class="citetitle">f statement</em></a>).
    </p>
        <p>
      <span class="emphasis"><em>fnsf</em></span> -- pre-existing table with scaling
      function coefficients. 
    </p>
        <p>
      <span class="emphasis"><em>seq</em></span> -- non-negative integer number which
      corresponds to sequence of low-pass and high-pass mirror filters
      during deconvolution procedure. 
    </p>
        <p>
      <span class="emphasis"><em>rescale</em></span> -- if not zero the table is not rescaled
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp78776784"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GENwave routine. It uses the file
      <a class="ulink" href="examples/genwave.csd" target="_top"><em class="citetitle">genwave.csd</em></a>. 
      </p>
        <div class="example">
          <a id="idp78777768"></a>
          <p class="title">
            <strong>Example 1078. Example of the GENwave routine.</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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o 0dbfs.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">nchnls</span> <span class="op">=</span> 1
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="opc">zakinit</span> 3,1

<span class="oblock">instr</span> 1 <span class="comment">; wavelet synth instrument</span>
iamp  <span class="op">=</span>	 p4<span class="comment">; scaling factor of wavelets</span>
ifreq <span class="op">=</span>	 p5<span class="comment">; frequency of wavelets</span>
itab  <span class="op">=</span>	 p6<span class="comment">; selected wavelet function</span>
inum  <span class="op">=</span>  p7<span class="comment">; number of wavelets to be created</span>
a1 <span class="opc">osciln</span> p4, p5, p6, p7 
<span class="opc">out</span> a1
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2 <span class="comment">; wavelet analysis intrument </span>
a1 <span class="opc">soundin</span> "fox.wav"
<span class="comment">; Decomposition Structure:</span>
<span class="comment">;     1 LEVEL  2 LEVEL</span>
<span class="comment">;     HP-&gt;ah1  </span>
<span class="comment">; a1-&gt;|	       HP(up2)-&gt;ah2</span>
<span class="comment">;     LP-&gt;al1-&gt;|</span>
<span class="comment">;	       LP(up2)-&gt;al2</span>
<span class="comment">;</span>
ain <span class="op">=</span> a1<span class="op">*</span>.5<span class="comment">; attenuate input signal</span>
	   <span class="comment">; since wavelet coefficients</span>
	   <span class="comment">; could reach big values  </span>
ah1 <span class="opc">dconv</span> ain,ftlen(8),8
al1 <span class="opc">dconv</span> ain,ftlen(7),7
ah2 <span class="opc">dconv</span> al1,ftlen(10),10
al2 <span class="opc">dconv</span> al1,ftlen(9),9

<span class="opc">zaw</span> ah1,0
<span class="opc">zaw</span> al1,1
<span class="opc">zaw</span> ah2,2
<span class="opc">zaw</span> al2,3

aout <span class="opc">zar</span> p4
<span class="opc">out</span> aout
<span class="opc">zacl</span> 0,3
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="comment">; First of all, we need several FIR filters which are capable </span>
<span class="comment">; to produce wavelet families.</span>
<span class="comment">; One can input filter coefficients manualy using GEN02 </span>
<span class="comment">; or read them from text file.</span>
<span class="comment">; Most of compact-supported wavelet coefficients can be obtained from</span>
<span class="comment">; Wavelet Browser by PyWavelets wavelets.pybytes.com</span>
<span class="comment">; You can select family and order of filter</span>
<span class="comment">; then copy desired coefficients into txt file.</span>
<span class="comment">; Notice that for correct interpretation of results you should use</span>
<span class="comment">; coeffs of Decomposition low-pass filter.</span>

<span class="comment">; Daubechies 2 </span>
<span class="stamnt">f</span> 1 0 4 -2 -0.1294095226 0.2241438680 0.8365163037 0.4829629131
<span class="comment">; Symlet 10</span>
<span class="stamnt">f</span> 2 0 0 -23 "sym10.txt"

<span class="comment">; Now we want to produce some wavelet granules.</span>
<span class="comment">; They can be used in wavelet synthesis etc.</span>
<span class="comment">; Tables of large sizes should produce smoother wavelets.</span>
<span class="comment">; We take array of filter coefficients from ftable 1</span>
<span class="comment">; and deconvolve it until output length of 16384.</span>
<span class="comment">; The order of filters through the deconvolution process</span>
<span class="comment">; is given by 14 which is 1110 in binary.</span>
<span class="comment">; So the first filter is LP ('0') and others are HP ('1').</span>
<span class="stamnt">f</span> 3 0 16384 "wave" 1 14 0
<span class="stamnt">f</span> 4 0 16384 "wave" 2 1  0
<span class="stamnt">f</span> 5 0 16384 "wave" 2 7  0
<span class="stamnt">f</span> 6 0 16384 "wave" 2 6  0
<span class="comment">; The main purpose of using wavelets is wavelet transform.</span>
<span class="comment">; It is not that easy to perform a classic DWT in Csound since downsampling</span>
<span class="comment">; of audio signal is needed at each step of wavelet decomposition.</span>
<span class="comment">; Anyway, using GENwave it is possible to create a number of upsampled</span>
<span class="comment">; wavelets and perform a so-called undecimated wavelet transform </span>
<span class="comment">; aka stationary wavelet transform (and it is even better).</span>
<span class="comment">; So we need some upsampled childs of mother wavelet. </span>
<span class="stamnt">f</span> 7 0 16 "wave" 1 0 -1 <span class="comment">;db2 scaling function for 1st iteration</span>
<span class="stamnt">f</span> 8 0 16 "wave" 1 1 -1 <span class="comment">;db2 wavelet function for 1st iteration</span>
<span class="stamnt">f</span> 9 0 32 "wave" 1 0 -1 <span class="comment">;db2 scaling function for 2nd iteration</span>
<span class="stamnt">f</span> 10 0 32 "wave" 1 1 -1 <span class="comment">;db2 wavelet function for 2nd iteration</span>

<span class="comment">; Let's hear how some wavelets could sound..</span>
<span class="comment">;		 amp frq wave	 times</span>
<span class="stamnt">i</span> 1 0	 1	 0.6 15	 3	 8
<span class="stamnt">i</span> 1 0.5	 .	 0.9 20  4	 5
<span class="stamnt">i</span> 1 0.9  .	 0.7 8	 5	 .
<span class="stamnt">i</span> 1 1.1	 .	 0.4 30  6	 9

<span class="comment">; Now try to decompose input file using wavelets</span>
<span class="stamnt">i</span> 2 2 4  1<span class="comment">; approximation 1st level</span>
<span class="stamnt">i</span> 2 5 .  2<span class="comment">; details 2nd level</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />  
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp78780112"></a>
        <h2>See Also</h2>
        <p>
       Ingrid Daubechies. Ten Lectures on Wavelets, SIAM 1992.
    </p>
        <p>
      Pedro A.G. Batista. An Introduction to Sound Synthesis with
      Wavelet Packets, Csound Book CD Chapters, MIT 2000. 
    </p>
        <p>
      Victor M. Wickerhauser. Acoustic Signal Compression with Wavelet
      Packets, Yale 1992. 
     </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp78781400"></a>
        <h2>Credits</h2>
        <p>Written by Gleb Rogozinsky</p>
        <p>Saint-Petersburg University of Film and Television</p>
        <p>Saint-Petersburg, Russia</p>
        <p>April 2012</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GENfarey.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="DeprecatedTop.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GENfarey </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Deprecated Orchestra Opcodes and GEN Routines</td>
        </tr>
      </table>
    </div>
  </body>
</html>