<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="linenr">
  <refmeta>
    <refentrytitle>linenr</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>linenr</refname>
    <refpurpose>
      The linen opcode extended with a final release segment.
      <indexterm id="IndexLinenr"><primary>linenr</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>linenr</emphasis> -- same as <link linkend="linen"><citetitle>linen</citetitle></link> except that the final segment is entered only on sensing a MIDI note release. The note is then extended by the decay time.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis>ar <command>linenr</command> xamp, irise, idec, iatdec</synopsis>

    <synopsis>kr <command>linenr</command> kamp, irise, idec, iatdec</synopsis>
 </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>irise</emphasis> -- rise time in seconds. A zero or negative value signifies no rise modification.
    </para>

    <para>
      <emphasis>idur</emphasis> -- overall duration in seconds. A zero or negative value will cause initialization to be skipped.
    </para>

    <para>
      <emphasis>idec</emphasis> -- decay time in seconds. Zero means no decay. An <emphasis>idec</emphasis> &gt; <emphasis>idur</emphasis> will cause a truncated decay.
    </para>

    <para>
      <emphasis>iatdec</emphasis> -- attenuation factor by which the closing steady state value is reduced exponentially over the decay period. This value must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>kamp, xamp</emphasis> -- input amplitude signal.
    </para>

    <para>
      <emphasis>linenr</emphasis> is unique within Csound in containing a <emphasis>note-off sensor</emphasis> and <emphasis>release time extender</emphasis>. When it senses either a score event termination or a MIDI noteoff, it will immediately extend the performance time of the current instrument by <emphasis>idec</emphasis> seconds, then execute an exponential decay towards the factor <emphasis>iatdec</emphasis>. For two or more units in an instrument, extension is by the greatest <emphasis>idec</emphasis>.
    </para>

    <para>
      <emphasis>linenr</emphasis> is an example of the special Csound <quote>r</quote> units that contain a note-off sensor and release time extender. When each senses a score event termination or a MIDI noteoff, it will immediately extend the performance time of the current instrument by <emphasis>idec</emphasis> seconds unless made independent by <emphasis>irind</emphasis>. Then it will begin a decay from wherever it was at the time.
    </para>

    <para>
      These <quote>r</quote> units can also be modified by MIDI noteoff velocities (see veloffs). If the <emphasis>irind</emphasis> flag is on (non-zero), the overall performance time is unaffected by note-off and veloff data.
    </para>

    <formalpara>
      <title>Multiple <quote>r</quote> units</title>
      <para>
         When two or more <quote>r</quote> units occur in the same instrument it is usual to have only one of them influence the overall note duration. This is normally the master amplitude unit. Other units controlling, say, filter motion can still be sensitive to note-off commands while not affecting the duration by making them independent (<emphasis>irind</emphasis> non-zero). Depending on their own <emphasis>idec</emphasis> (release time) values, independent <quote>r</quote> units may or may not reach their final destinations before the instrument terminates. If they do, they will simply hold their target values until termination. If two or more <quote>r</quote> units are simultaneously master, note extension is by the greatest <emphasis>idec</emphasis>.
      </para>
    </formalpara>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="envlpx"><citetitle>envlpx</citetitle></link>,
      <link linkend="envlpxr"><citetitle>envlpxr</citetitle></link>,
      <link linkend="linen"><citetitle>linen</citetitle></link>
    </para>
  </refsect1>
</refentry>
