<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="xtratim">
  <refmeta>
    <refentrytitle>xtratim</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>xtratim</refname>

    <refpurpose>
      Extend the duration of real-time generated events.
      <indexterm id="IndexXtratim"><primary>xtratim</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      Extend the duration of real-time generated events and handle their extra life (see also <link linkend="linenr"><citetitle>linenr</citetitle></link>).
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis><command>xtratim</command> iextradur</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>iextradur</emphasis> -- additional duration of current instrument instance
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>xtratim</emphasis> extends current MIDI-activated note duration of <emphasis>iextradur</emphasis> seconds after the corresponding noteoff message has deactivated current note itself. This opcode has no output arguments.
    </para>

    <para>
       This opcode is useful for implementing complex release-oriented envelopes.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>
    <para>
      <informalexample>
        <programlisting>
 <emphasis>instr</emphasis> 1 ;allows complex ADSR envelope with MIDI events
  inum <emphasis>notnum</emphasis>
  icps <emphasis>cpsmidi</emphasis>
  iamp <emphasis>ampmid</emphasis>i 4000
 ;
 ;------- complex envelope block ------
  <emphasis>xtratim</emphasis> 1 ;extra-time, i.e. release dur
  krel <emphasis>init</emphasis> 0
  krel <emphasis>release</emphasis> ;outputs release-stage flag (0 or 1 values)
  if (krel  .5) <emphasis>kgoto</emphasis> rel ;if in release-stage goto release section
 ;
 ;************ attack and sustain section ***********
  kmp1 <emphasis>linseg</emphasis> 0, .03, 1, .05, 1, .07, 0, .08, .5, 4, 1, 50, 1
  kmp = kmp1*iamp
   <emphasis>kgoto</emphasis> done
 ;
 ;--------- release section --------
   rel:
  kmp2 <emphasis>linseg</emphasis> 1, .3, .2, .7, 0
  kmp = kmp1*kmp2*iamp
  done:
 ;------
  a1 <emphasis>oscili</emphasis> kmp, icps, 1
  <emphasis>out</emphasis> a1
 <emphasis>endin</emphasis>
        </programlisting>
      </informalexample>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="linenr"><citetitle>linenr</citetitle></link>, 
      <link linkend="release"><citetitle>release</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &namegabriel;</member>
        <member>Italy</member>
      </simplelist>
    </para>

    <para>New in Csound version 3.47</para>
  </refsect1>
</refentry>
