<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="adsr">
  <refmeta>
    <refentrytitle>adsr</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>adsr</refname>
    <refpurpose>
      Calculates the classical ADSR envelope using linear segments.
      <indexterm id="IndexAdsr"><primary>adsr</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Calculates the classical ADSR envelope using linear segments.
   </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis>ar <command>adsr</command> iatt, idec, islev, irel [, idel]</synopsis>

    <synopsis>kr <command>adsr</command> iatt, idec, islev, irel [, idel]</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>iatt</emphasis> -- duration of attack phase
    </para>

    <para>
      <emphasis>idec</emphasis> -- duration of decay
    </para>

    <para>
      <emphasis>islev</emphasis> -- level for sustain phase
    </para>

    <para>
      <emphasis>irel</emphasis> -- duration of release phase
    </para>

    <para>
      <emphasis>idel</emphasis> -- period of zero before the envelope starts
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      The envelope is the range 0 to 1 and may need to be scaled further. The envelope may be described as:
      <mediaobject>
        <imageobject>
          <imagedata fileref="images/adsr.png" format="PNG">
        </imageobject>

        <textobject>
          <phrase>Picture of an ADSR envelope.</phrase>
        </textobject>
        
        <caption>
          <para>Picture of an ADSR envelope.</para>
        </caption>
      </mediaobject>
    </para>

    <para>
       The length of the sustain is calculated from the length of the note. This means <emphasis>adsr</emphasis> is not suitable for use with MIDI events. The opcode <link linkend="madsr"><citetitle>madsr</citetitle></link> uses the <link linkend="linsegr"><citetitle>linsegr</citetitle></link> mechanism, and so can be used in MIDI applications.
    </para>

    <para>
      <emphasis>adsr</emphasis> is new in Csound version 3.49.
    </para>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the adsr opcode. It uses the files <ulink url="examples/adsr.orc"><citetitle>adsr.orc</citetitle></ulink> and <ulink url="examples/adsr.sco"><citetitle>adsr.sco</citetitle></ulink>.

      <example>
        <title>Example of the adsr opcode.</title>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/adsr.orc" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>

        <programlisting>
<inlinemediaobject>
            <imageobject>
              <imagedata fileref="examples/adsr.sco" format="linespecific">
            </imageobject>
          </inlinemediaobject>
        </programlisting>
      </example>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="madsr"><citetitle>madsr</citetitle></link>,
      <link linkend="mxadsr"><citetitle>mxadsr</citetitle></link>,
      <link linkend="xadsr"><citetitle>xadsr</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>Example written by &namekevin;.</para>
  </refsect1>
</refentry>
