<?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>GEN49</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="GEN43.html" title="GEN43" /> <link rel="next" href="GEN51.html" title="GEN51" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">GEN49</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="GEN43.html">Prev</a> </td> <th width="60%" align="center">Score Statements and GEN Routines</th> <td width="20%" align="right"> <a accesskey="n" href="GEN51.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="GEN49"> <a id="GEN49"></a> <div class="titlepage"></div> <a id="IndexGEN49" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">GEN49</span> </h2> <p>GEN49 — Transfers data from an MP3 soundfile into a function table. </p> </div> <div class="refsect1" title="Description"> <a id="idp78432752"></a> <h2>Description</h2> <p> This subroutine transfers data from an MP3 soundfile into a function table. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp78433424"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>f</strong></span># time size 49 filcod skiptime format</pre> </div> <div class="refsect1" title="Performance"> <a id="idp78434400"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>size</em></span> -- number of points in the table. Ordinarily a power of 2 or a 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>); the maximum tablesize is 16777216 (2<sup>24</sup>) points. The allocation of table memory can be <span class="emphasis"><em>deferred</em></span> by setting this parameter to 0; the size allocated is then the number of points in the file (probably not a power-of-2), and the table is not usable by normal oscillators, but it is usable by a <a class="link" href="loscil.html" title="loscil"><em class="citetitle">loscil</em></a> unit. The soundfile can also be mono or stereo. </p> <p> <span class="emphasis"><em>filcod</em></span> -- integer or character-string denoting the source soundfile name. An integer denotes the file <span class="emphasis"><em>soundin</em></span>.<span class="emphasis"><em>filcod</em></span> ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the file is sought first in the current directory, then in that given by the environment variable <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SSDIR</em></a> (if defined) then by <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SFDIR</em></a>. See also <a class="link" href="soundin.html" title="soundin"><em class="citetitle">soundin</em></a>. </p> <p> <span class="emphasis"><em>skiptime</em></span> -- begin reading at <span class="emphasis"><em>skiptime</em></span> seconds into the file. </p> <p> <span class="emphasis"><em>format</em></span> -- specifies the audio data-file format required: </p> <div class="literallayout"> <p><br /> 1 - Mono file 3 - First channel (left)<br /> 2 - Stereo file 4 - Second channel (right)<br /> </p> </div> <p> </p> <p> If <span class="emphasis"><em>format</em></span> = 0 the sample format is taken from the soundfile header. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p> Reading stops at end-of-file or when the table is full. Table locations not filled will contain zeros. </p> </li> <li class="listitem"> <p> If p4 is positive, the table will be post-normalized (rescaled to a maximum absolute value of 1 after generation). A negative p4 will cause rescaling to be skipped. </p> </li> </ul> </div> <p> </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Examples"> <a id="idp78470288"></a> <h2>Examples</h2> <p> Here is an example of the GEN49 routine. It uses the files <a class="ulink" href="examples/gen49.csd" target="_top"><em class="citetitle">gen49.csd</em></a>. </p> <div class="example"> <a id="idp78471256"></a> <p class="title"> <strong>Example 1070. An example of the GEN49 routine.</strong> </p> <div class="example-contents"> <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 gen49.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 kcps <span class="op">=</span> <span class="ohdr">sr</span><span class="op">/</span><span class="opc">ftlen</span>(1) asig <span class="opc">oscil</span> .8, kcps, 1 <span class="opc">outs</span> asig, asig <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span> 1 0 131072 49 "beats.mp3" 0 1 <span class="comment">;read an audio file (using GEN49).</span> <span class="stamnt">i</span> 1 0 2 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> <span>This is the diagram of the waveforms of the GEN49 routine, as used in the example:</span> </p> <div class="mediaobject"> <img src="images/gen49.png" alt="f 1 0 131072 49 "beats.mp3" 0 1" /> <div class="caption"> <p>f 1 0 131072 49 "beats.mp3" 0 1</p> </div> </div> <p> </p> </div> <div class="refsect1" title="Credits"> <a id="idp78474336"></a> <h2>Credits</h2> <p>Written by John ffitch</p> <p>February 2009.</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="GEN43.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="GEN51.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">GEN43 </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> GEN51</td> </tr> </table> </div> </body> </html>