<!-- Converted to DocBook/SGML by Kevin Conder -->
<chapter id="UtilityTop">
  <chapterinfo>
    <author>
      <firstname>Dan</firstname>
      <surname>Ellis</surname>

      <affiliation>
        <orgname>MIT Media Lab</orgname>
 
        <address>
          <city>Cambrige</city>
          <state>Massachussetts</state>
        </address>
      </affiliation>
    </author>
  </chapterinfo>

  <title>The Utility Programs</title>

  <para>
    The Csound Utilities are <emphasis>soundfile preprocessing</emphasis> programs that return information on a soundfile or create some analyzed version of it for use by certain Csound generators. Though different in goals, they share a common soundfile access mechanism and are describable as a set. The Soundfile Utility programs can be invoked in two equivalent forms:
    <cmdsynopsis>
        <command>csound</command>
        <arg><replaceable>-U utilname</replaceable></arg>
        <arg><option>flags</option></arg>
        <arg><replaceable>filenames</replaceable></arg>
    </cmdsynopsis> 

    <cmdsynopsis>
        <command>utilname</command>
        <arg><option>flags</option></arg>
        <arg><replaceable>filenames</replaceable></arg>
    </cmdsynopsis> 
  </para>

  <para>
    In the first, the utility is invoked as part of the Csound executable, while in the second it is called as a standalone program. The second is smaller by about 200K, but the two forms are identical in function. The first is convenient in not requiring the maintenance and use of several independent programs - one program does all. When using this form, a <link linkend="FlagsMinusUpperU"><citetitle>-U flag</citetitle></link> detected in the command line will cause all subsequent flags and names to be interpreted as per the named utility; i.e. Csound generation will not occur, and the program will terminate at the end of utility processing.
  </para>

  <section id="UtilityDir">
    <title>Directories.</title> 

    <para>
      Filenames are of two kinds, source soundfiles and resultant analysis files. Each has a hierarchical naming convention, influenced by the directory from which the Utility is invoked. Source soundfiles with a full pathname (begins with dot (.), slash (/), or for ThinkC includes a colon (:)), will be sought only in the directory named. Soundfiles without a path will be sought first in the current directory, then in the directory named by the SSDIR environment variable (if defined), then in the directory named by SFDIR. An unsuccessful search will return a &quot;cannot open&quot; error.
    </para>

    <para>
      Resultant analysis files are written into the current directory, or to the named directory if a path is included. It is tidy to keep analysis files separate from sound files, usually in a separate directory known to the SADIR variable. Analysis is conveniently run from within the SADIR directory. When an analysis file is later invoked by a Csound generator it is sought first in the current directory, then in the directory defined by SADIR.
    </para>
  </section>

  <section id="UtilitySoundfile">
    <title>Soundfile Formats.</title>

    <para>
      Csound can read and write audio files in a variety of formats. Write formats are described by Csound command flags. On reading, the format is determined from the soundfile header, and the data automatically converted to floating-point during internal processing. When Csound is installed on a host with local soundfile conventions (SUN, NeXT, Macintosh) it may conditionally include local packaging code which creates soundfiles not portable to other hosts. However, Csound on any host can always generate and read AIFF files, which is thus a portable format. Sampled sound libraries are typically AIFF, and the variable SSDIR usually points to a directory of such sounds. If defined, the SSDIR directory is in the search path during soundfile access. Note that some AIFF sampled sounds have an audio looping feature for sustained performance; the analysis programs will traverse any loop segment once only.
    </para>

    <para>
      For soundfiles without headers, an SR value may be supplied by the <link linkend="FlagsMinusLowerR"><citetitle>-R flag</citetitle></link> (or its default). If both the <link linkend="sr"><citetitle>SR header</citetitle></link> and the command-line flag are present, the flag value will override the header.
    </para>

    <para>
      When sound is accessed by the audio Analysis programs , only a single channel is read. For stereo or quad files, the default is channel one; alternate channels may be obtained on request. 
    </para>
  </section>

  <section id="UtilityCredits">
    <title>Credits</title>
    <para>Dan Ellis</para>
    <para>MIT Media Lab</para>
    <para>Cambrige, Massachussetts</para>
  </section>

  &utilityanalysis;
  &utilityqueries;
  &utilityconvert;

</chapter>
