Sophie

Sophie

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

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>sfplay3</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="sfpassign.html" title="sfpassign" />
    <link rel="next" href="sfplay3m.html" title="sfplay3m" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">sfplay3</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="sfpassign.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="sfplay3m.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="sfplay3">
      <a id="sfplay3"></a>
      <div class="titlepage"></div>
      <a id="IndexSfplay3" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">sfplay3</span>
        </h2>
        <p>sfplay3 — 
      Plays a SoundFont2 (SF2) sample preset, generating a stereo sound with cubic interpolation.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp42653648"></a>
        <h2>Description</h2>
        <p>
      Plays a SoundFont2 (SF2) sample preset, generating a stereo sound with cubic interpolation. These opcodes allow management the sample-structure of SF2 files. In order to understand the usage of these opcodes, the user must have some knowledge of the SF2 format, so a brief description of this format can be found in the <a class="link" href="MiscSf2.html" title="Appendix G. SoundFont2 File Format"><em class="citetitle">SoundFont2 File Format Appendix</em></a>.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp42655016"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ar1, ar2 <span class="command"><strong>sfplay3</strong></span> ivel, inotenum, xamp, xfreq, ipreindex [, iflag] [, ioffset] [, ienv]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp42703256"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ivel</em></span> -- velocity value
    </p>
        <p>
      <span class="emphasis"><em>inotenum</em></span> -- MIDI note number value
    </p>
        <p>
      <span class="emphasis"><em>ipreindex</em></span> -- preset index
    </p>
        <p>
      <span class="emphasis"><em>iflag</em></span> (optional) -- flag regarding the behavior of <span class="emphasis"><em>xfreq</em></span> and <span class="emphasis"><em>inotenum</em></span>
    </p>
        <p>
      <span class="emphasis"><em>ioffset</em></span> (optional) -- start playing at offset, in samples.
    </p>
        <p>
      <span class="emphasis"><em>ienv</em></span> (optional) -- enables and determines amplitude envelope. 0 = no envelope, 1 = linear attack and decay, 2 = linear attack, exponential decay (see below). Default = 0.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp42706880"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>xamp</em></span> -- amplitude correction factor
    </p>
        <p>
      <span class="emphasis"><em>xfreq</em></span> -- frequency value or frequency multiplier, depending by <span class="emphasis"><em>iflag</em></span>. When <span class="emphasis"><em>iflag</em></span> = 0, <span class="emphasis"><em>xfreq</em></span> is a multiplier of a the default frequency, assigned by SF2 preset to the <span class="emphasis"><em>inotenum</em></span> value. When <span class="emphasis"><em>iflag</em></span> = 1, <span class="emphasis"><em>xfreq</em></span> is the absolute frequency of the output sound, in Hz. Default is 0.
    </p>
        <p>
      When <span class="emphasis"><em>iflag</em></span> = 0, <span class="emphasis"><em>inotenum</em></span> sets the frequency of the output according to the MIDI note number used, and <span class="emphasis"><em>xfreq</em></span> is used as a multiplier. When <span class="emphasis"><em>iflag</em></span> = 1, the frequency of the output, is set directly by <span class="emphasis"><em>xfreq</em></span>. This allows the user to use any kind of micro-tuning based scales. However, this method is designed to work correctly only with presets tuned to the default equal temperament. Attempts to use this method with a preset already having non-standard tunings, or with drum-kit-based presets, could give unexpected results.
    </p>
        <p>
      Adjustment of the amplitude can be done by varying the <span class="emphasis"><em>xamp</em></span> argument, which acts as a multiplier.
    </p>
        <p>
      Notice that both <span class="emphasis"><em>xamp</em></span> and <span class="emphasis"><em>xfreq</em></span> can use k-rate as well as a-rate signals. Both arguments must use variables of the same rate, or <span class="emphasis"><em>sfplay3</em></span> will not work correctly. <span class="emphasis"><em>ipreindex</em></span> must contain the number of a previously assigned preset, or Csound will crash.
    </p>
        <p>
      The <span class="emphasis"><em>ioffset</em></span> parameter allows the sound to start from a sample different than the first one. The user should make sure that its value is within the length of the specific sound. Otherwise, Csound will probably crash.
    </p>
        <p>
      The <span class="emphasis"><em>ienv</em></span> parameter enables and determines the type of amplitude envelope used. The default value is 0, or no envelope. If <span class="emphasis"><em>ienv</em></span> is set to 1, the attack and decay portions are linear. If set to 2, the attack is linear and the decay is exponential. The release portion of the envelope has not yet been implemented.
    </p>
        <p>
      <span class="emphasis"><em>sfplay3</em></span> plays a preset, generating a stereo sound with cubic interpolation. <span class="emphasis"><em>ivel</em></span> does not directly affect the amplitude of the output, but informs <span class="emphasis"><em>sfplay3</em></span> about which sample should be chosen in multi-sample, velocity-split presets.
    </p>
        <p>
      <span class="emphasis"><em>sfplay3</em></span> is a cubic-interpolation version of <a class="link" href="sfplay.html" title="sfplay"><em class="citetitle">sfplay</em></a>. Difference of sound-quality is noticeable specially in bass-frequency-transposed samples. In high-freq-transposed samples the difference is less noticeable, and I suggest to use linear-interpolation versions, because they are faster.
    </p>
        <p>
      These opcodes only support the sample structure of SF2 files. The modulator structure of the SoundFont2 format is not supported in Csound. Any modulation or processing to the sample data is left to the Csound user, bypassing all restrictions forced by the SF2 standard.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp42717568"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the sfplay3 opcode. It uses the file <a class="ulink" href="examples/sfplay3.csd" target="_top"><em class="citetitle">sfplay3.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp42718544"></a>
          <p class="title">
            <strong>Example 768. Example of the sfplay3 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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
 
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac -+rtmidi=virtual -M0 <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 sfplay3.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">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 

gitwelve <span class="ohdr">ftgen</span> 1, 0, 16, <span class="op">-</span>2, 12, 2, 440, 69, 1, 16<span class="op">/</span>15, 9<span class="op">/</span>8, 6<span class="op">/</span>5, 5<span class="op">/</span>4, 4<span class="op">/</span>3, 7<span class="op">/</span>5, 3<span class="op">/</span>2, 8<span class="op">/</span>5, 5<span class="op">/</span>3, 9<span class="op">/</span>5, 15<span class="op">/</span>8, 2 
givife   <span class="ohdr">ftgen</span> 2, 0, 16, <span class="op">-</span>2, 5, 2, 261.659, 60, 1, 1.1486, 1.3195, 1.5157, 1.7411, 2.00

giSF	<span class="opc">sfload</span>	"01hpschd.sf2" 
        <span class="opc">sfplist</span> giSF 
gipre	<span class="opc">sfpreset</span> 0, 0, giSF, 0 

<span class="oblock">instr</span> 1 

	<span class="opc">mididefault</span>	60, p3
	<span class="opc">midinoteonkey</span>	p4, p5
ikey	<span class="op">=</span> p4
ivel	<span class="op">=</span> p5
aenv    <span class="opc">linsegr</span>	1, 1, 1, 1, 0			<span class="comment">;envelope</span>
icps    <span class="opc">cpstuni</span>	ikey, gitwelve 			<span class="comment">;12 tones per octave</span>
iamp    <span class="op">=</span> 0.0004				<span class="comment">;scale amplitude</span>
iamp    <span class="op">=</span> iamp <span class="op">*</span> ivel <span class="op">*</span> 1<span class="op">/</span>128 			<span class="comment">;make velocity-dependent</span>
aL, aR	<span class="opc">sfplay3</span> ivel, ikey, iamp, icps, gipre, 1 
aL      <span class="op">=</span> aL <span class="op">*</span> aenv 
aR      <span class="op">=</span> aR <span class="op">*</span> aenv 
        <span class="opc">outs</span> aL, aR 

<span class="oblock">endin</span> 

<span class="oblock">instr</span> 2 

	<span class="opc">mididefault</span>	60, p3
	<span class="opc">midinoteonkey</span>	p4, p5
ikey	<span class="op">=</span> p4
ivel	<span class="op">=</span> p5
aenv    <span class="opc">linsegr</span>	1, 1, 1, 1, 0			<span class="comment">;envelope</span>
icps    <span class="opc">cpstuni</span>	ikey, givife			<span class="comment">;5 tones per octave</span>
iamp    <span class="op">=</span> 0.0004				<span class="comment">;scale amplitude</span>
iamp    <span class="op">=</span> iamp <span class="op">*</span> ivel <span class="op">*</span> 1<span class="op">/</span>128 			<span class="comment">;make velocity-dependent</span>
aL, aR	<span class="opc">sfplay3</span> ivel, ikey, iamp, icps, gipre, 1 
aL      <span class="op">=</span> aL <span class="op">*</span> aenv 
aR      <span class="op">=</span> aR <span class="op">*</span> aenv 
        <span class="opc">outs</span> aL, aR 

<span class="oblock">endin</span> 
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
 
<span class="stamnt">f</span>0 60	<span class="comment">;play for 60 seconds</span>
<span class="comment">;instr.1 using ftable 1</span>
<span class="stamnt">i</span>1 0 1 60 100 
<span class="stamnt">i</span>1 + 1 62 &lt;  
<span class="stamnt">i</span>1 + 1 65 &lt;   
<span class="stamnt">i</span>1 + 1 69 40  

<span class="comment">;instr.2 using ftable 2</span>
<span class="stamnt">i</span>2 5 1 60 100 
<span class="stamnt">i</span>2 + 1 62 &lt;   
<span class="stamnt">i</span>2 + 1 65 &lt;   
<span class="stamnt">i</span>2 + 1 69 40  
<span class="stamnt">e</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="idp42720824"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="sfilist.html" title="sfilist"><em class="citetitle">sfilist</em></a>,
      <a class="link" href="sfinstr3.html" title="sfinstr3"><em class="citetitle">sfinstr3</em></a>,
      <a class="link" href="sfinstr3m.html" title="sfinstr3m"><em class="citetitle">sfinstr3m</em></a>,
      <a class="link" href="sfinstr.html" title="sfinstr"><em class="citetitle">sfinstr</em></a>,
      <a class="link" href="sfinstrm.html" title="sfinstrm"><em class="citetitle">sfinstrm</em></a>,
      <a class="link" href="sfload.html" title="sfload"><em class="citetitle">sfload</em></a>,
      <a class="link" href="sfpassign.html" title="sfpassign"><em class="citetitle">sfpassign</em></a>,
      <a class="link" href="sfplay3m.html" title="sfplay3m"><em class="citetitle">sfplay3m</em></a>,
      <a class="link" href="sfplaym.html" title="sfplaym"><em class="citetitle">sfplaym</em></a>,
      <a class="link" href="sfplay.html" title="sfplay"><em class="citetitle">sfplay</em></a>,
      <a class="link" href="sfplist.html" title="sfplist"><em class="citetitle">sfplist</em></a>,
      <a class="link" href="sfpreset.html" title="sfpreset"><em class="citetitle">sfpreset</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp42727120"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
          <tr>
            <td>May 2000</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound Version 4.07</p>
        <p>New optional parameter <span class="emphasis"><em>ienv</em></span> in version 5.09</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="sfpassign.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="sfplay3m.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">sfpassign </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> sfplay3m</td>
        </tr>
      </table>
    </div>
  </body>
</html>