<!-- Converted to DocBook/SGML by Kevin Conder -->
<section id="OrchKvar">
  <title>Constants and Variables</title>

  <para>
    <emphasis>constants</emphasis> are floating point numbers, such as 1, 3.14159, or -73.45. They are available continuously and do not change in value.
  </para>

  <para>
    <emphasis>variables</emphasis> are named cells containing numbers. They are available continuously and may be updated at one of the four update rates (setup only, i-rate, k-rate, or a-rate). i- and k-rate variables are scalars (i.e. they take on only one value at any given time) and are primarily used to store and recall controlling data, that is, data that changes at the note rate (for i-rate variables) or at the control rate (for k-rate variables). i- and k-variables are therefore useful for storing note parameter values, pitches, durations, slow-moving frequencies, vibratos, etc. a-rate variables, on the other hand, are arrays or vectors of information. Though renewed on the same perf-time control pass as k-rate variables, these array cells represent a finer resolution of time by dividing the control period into sample periods (see <link linkend="ksmps"><citetitle>ksmps</citetitle></link>). a-rate variables are used to store and recall data changing at the audio sampling rate (e.g. output signals of oscillators, filters, etc.).
  </para>

  <para>
    A further distinction is that between local and global variables. <emphasis>local</emphasis> variables are private to a particular instrument, and cannot be read from or written into by any other instrument. Their values are preserved, and they may carry information from pass to pass (e.g. from initialization time to performance time) within a single instrument. Local variable names begin with the letter <emphasis>p, i, k</emphasis>, or <emphasis>a</emphasis>. The same local variable name may appear in two or more different instrument blocks without conflict.
  </para>

  <para id="GlobalVariables">
    <emphasis>global</emphasis> variables are cells that are accessible by all instruments. The names are either like local names preceded by the letter <emphasis>g</emphasis>, or are special reserved symbols. Global variables are used for broadcasting general values, for communicating between instruments (semaphores), or for sending sound from one instrument to another (e.g. mixing prior to reverberation).
  </para>

  <para>
    given these distinctions, there are eight forms of local and global variables:
  </para>

  <para>
    <table id="VariableTypes" frame="all">
      <title>Types of Variables</title>
      <tgroup cols="4" colsep="1" rowsep="1">
        <thead>
          <row>
            <entry>Type</entry>
            <entry>When Renewable</entry>
            <entry>Local</entry>
            <entry>Global</entry>
          </row>
        </thead>

        <tbody>
          <row>
            <entry>reserved symbols</entry>
            <entry>permanent</entry>
            <entry> -- </entry>
            <entry>r symbol</entry>
          </row>

          <row>
            <entry>score pfields</entry>
            <entry>i-time</entry>
            <entry>p number</entry>
            <entry> -- </entry>
          </row>

          <row>
            <entry>v-set symbols</entry>
            <entry>i-time</entry>
            <entry>v number</entry>
            <entry>gv number</entry>
          </row>

          <row>
            <entry>init variables</entry>
            <entry>i-time</entry>
            <entry>i name</entry>
            <entry>gi name </entry>
          </row>

          <row>
            <entry>MIDI controllers</entry>
            <entry>any time</entry>
            <entry>c number</entry>
            <entry> -- </entry>
          </row>

          <row>
            <entry>control signals</entry>
            <entry>p-time, k-rate</entry>
            <entry>k name</entry>
            <entry>gk</entry>
          </row>

          <row>
            <entry>audio signals</entry>
            <entry>p-time, k-rate</entry>
            <entry>a name</entry>
            <entry>ga name</entry>
          </row>

          <row>
            <entry>spectral data types</entry>
            <entry>k-rate</entry>
            <entry>w name</entry>
            <entry> -- </entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </para>

  <para>
    where <emphasis>rsymbol</emphasis> is a special reserved symbol (e.g. <emphasis>sr, kr</emphasis>), <emphasis>number</emphasis> is a positive integer referring to a score pfield or sequence number, and <emphasis>name</emphasis> is a string of letters and/or digits with local or global meaning. As might be apparent, score parameters are local i-rate variables whose values are copied from the invoking score statement just prior to the init pass through an instrument, while MIDI controllers are variables which can be updated asynchronously from a MIDI file or MIDI device.
  </para>
</section>
