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

    <synopsis>kr <command>mxadsr</command> iatt, idec, islev, irel [, idel] [, ireltim]</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> (optional, default=0) -- period of zero before the envelope starts
    </para>

    <para>
      <emphasis>ireltim</emphasis> (optional, default=-1) -- Control release time after receiving a MIDI noteoff event. If less than zero, the longest release time given in the current instrument is used. If zero or more, the given value will be used for release time. Its default value is -1. (New in Csound 3.59 - not yet properly tested)
    </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 <emphasis>madsr</emphasis> uses the <link linkend="linsegr"><citetitle>linsegr</citetitle></link> mechanism, and so can be used in MIDI applications. The opcode <emphasis>mxadsr</emphasis> is identical to <emphasis>madsr</emphasis> except it uses exponential, rather than linear, line segments. 
    </para>

    <para>
      <emphasis>mxadsr</emphasis> is new in Csound version 3.51.
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="adsr"><citetitle>adsr</citetitle></link>,
      <link linkend="madsr"><citetitle>madsr</citetitle></link>,
      <link linkend="xadsr"><citetitle>xadsr</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>November 2002. Thanks to &namerasmus;, added documentation for the <emphasis>ireltim</emphasis> parameter.</para>
    <para>November 2003. Thanks to &namekanata;, fixed the link to the <emphasis>linsegr</emphasis> opcode.</para>

  </refsect1>
</refentry>
