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

  <refnamediv>
    <refname>ksmps</refname>

    <refpurpose>
      Sets the number of samples in a control period.
      <indexterm id="IndexKsmps"><primary>ksmps</primary></indexterm>
    </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para> 
      These statements are global value <link linkend="assign"><citetitle>assignments</citetitle></link>, made at the beginning of an orchestra, before any instrument block is defined. Their function is to set certain <link linkend="VariableTypes"><citetitle>reserved symbol variables</citetitle></link> that are required for performance. Once set, these reserved symbols can be used in expressions anywhere in the orchestra.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis><command>ksmps</command> = iarg</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>ksmps</emphasis> = (optional) -- set the number of samples in a control period. This value must equal<emphasis> sr/kr</emphasis>. The default value is 10.
    </para>

    <para>
      In addition, any <link linkend="GlobalVariables"><citetitle>global variable</citetitle></link> can be initialized by an <emphasis>init-time assignment</emphasis> anywhere before the first <link linkend="instr"><citetitle>instr statement</citetitle></link>.  All of the above assignments are run as instrument 0 (i-pass only) at the start of real performance.
    </para>

    <para>
      Beginning with Csound version 3.46, either <emphasis>ksmps</emphasis> may be omitted. Csound will attempt to calculate the omitted value from the specified values, but it should evaluate to an integer.
    </para>

    <warning>
      <title>Warning</title>
      <para>
        ksmps must be an integer value.
      </para>
    </warning>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      <informalexample>
        <programlisting>
<command>sr</command> = 10000
<command>kr</command> = 500
<command>ksmps</command> = 20
gi1 <command>= </command>sr/2.
ga <command>init </command>0
itranspose <command>= </command>octpch(.0l)
        </programlisting>
      </informalexample>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="kr"><citetitle>kr</citetitle></link>,
      <link linkend="nchnls"><citetitle>nchnls</citetitle></link>,
      <link linkend="sr"><citetitle>sr</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>Thanks to a note from &namegabriel;, added a warning about integer values.</para>
  </refsect1>
</refentry>
