Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > 5fcfcb7517038d1f44ab4e478e6e61fa > files > 2683

csound-doc-6.10.0-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>printks</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" />
    <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="printk.html" title="printk" />
    <link rel="next" href="printks2.html" title="printks2" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">printks</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="printk.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="printks2.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="printks"></a>
      <div class="titlepage"></div>
      <a id="IndexPrintks" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">printks</span>
        </h2>
        <p>printks — 
      Prints at k-rate using a printf() style syntax.
          </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901923128"></a>
        <h2>Description</h2>
        <p>
      Prints at k-rate using a printf() style syntax.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901921784"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>printks</strong></span> "string", itime [, kval1] [, kval2] [...]</pre>
      </div>
      <div class="refsect1">
        <a id="idm281472901854536"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>"string"</em></span> -- the text string to be printed. Can be up to 8192 characters and must be in double quotes.
    </p>
        <p>
      <span class="emphasis"><em>itime</em></span> -- time in seconds between printings.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901851800"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kval1, kval2, ...</em></span> (optional) -- The k-rate values to be printed. These are specified in <span class="emphasis"><em><span class="quote">“<span class="quote">string</span>”</span></em></span> with the standard C value specifier (%f, %d, etc.) in the order given.
    </p>
        <p>
      In Csound version 4.23, you can use as many <span class="emphasis"><em>kval</em></span> variables as you like. In versions prior to 4.23, you must specify 4 and only 4 kvals (using 0 for unused kvals).
    </p>
        <p>
      <span class="emphasis"><em>printks</em></span> prints numbers and text which can be i-time or k-rate values. <span class="emphasis"><em>printks</em></span> is highly flexible, and if used together with cursor positioning codes, could be used to write specific values to locations in the screen as the Csound processing proceeds.
    </p>
        <p>
      A special mode of operation allows this <span class="emphasis"><em>printks</em></span> to convert <span class="emphasis"><em>kval1</em></span> input parameter into a 0 to 255 value and to use it as the first character to be printed. This enables a Csound program to send arbitrary characters to the console. To achieve this, make the first character of the string a # and then, if desired continue with normal text and format specifiers.
    </p>
        <p>
      This opcode can be run on every k-cycle it is run in the instrument. To every accomplish this, set <span class="emphasis"><em>itime</em></span> to 0.
    </p>
        <p>
      When <span class="emphasis"><em>itime</em></span> is not 0, the opcode print on the first k-cycle it is called, and subsequently when every <span class="emphasis"><em>itime</em></span> period has elapsed. The time cycles start from the time the opcode is initialized - typically the initialization of the instrument.
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901841720"></a>
        <h2>Print Output Formatting</h2>
        <p>
      All standard C language printf() control characters may be used. For example, if <span class="emphasis"><em>kval1</em></span> = 153.26789 then some common formatting options are:

        </p>
        <div class="orderedlist">
          <ol class="orderedlist" type="1">
            <li class="listitem">
              <p>%f prints with full precision: 153.26789</p>
            </li>
            <li class="listitem">
              <p>%5.2f prints: 153.26</p>
            </li>
            <li class="listitem">
              <p>%d prints integers-only: 153</p>
            </li>
            <li class="listitem">
              <p>%c treats <span class="emphasis"><em>kval1</em></span> as an ascii character code. </p>
            </li>
          </ol>
        </div>
        <p>
    </p>
        <p>
      In addition to all the printf() codes, printks supports these useful character codes:

      </p>
        <div class="informaltable">
          <table class="informaltable" border="1">
            <colgroup>
              <col />
              <col />
            </colgroup>
            <thead>
              <tr>
                <th>printks Code</th>
                <th>Character Code</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>\\r, \\R, %r, or %R</td>
                <td>return character (\r)</td>
              </tr>
              <tr>
                <td>\\n, \\N, %n, %N</td>
                <td>newline character (\n)</td>
              </tr>
              <tr>
                <td>\\t, \\T, %t, or %T</td>
                <td>tab character (\t)</td>
              </tr>
              <tr>
                <td>%!</td>
                <td>semicolon character (;) This was needed because a <span class="quote">“<span class="quote">;</span>”</span> is interpreted as an comment.</td>
              </tr>
              <tr>
                <td>^</td>
                <td>escape character (0x1B)</td>
              </tr>
              <tr>
                <td>^ ^</td>
                <td>caret character (^)</td>
              </tr>
              <tr>
                <td>˜</td>
                <td>ESC[ (escape+[ is the escape sequence for ANSI consoles)</td>
              </tr>
              <tr>
                <td>˜˜</td>
                <td>tilde (˜)</td>
              </tr>
            </tbody>
          </table>
        </div>
        <p>
    </p>
        <p>
      For more information about printf() formatting, consult any C language documentation.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        Prior to version 4.23, only the %f format code was supported.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idm281472901819304"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the printks opcode. It uses the file <a class="ulink" href="examples/printks.csd" target="_top"><em class="citetitle">printks.csd</em></a>.

      </p>
        <div class="example">
          <a id="idm281472901817448"></a>
          <p class="title">
            <strong>Example 720. Example of the printks opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <div class="refsect1">
              <a id="idm281472722609592"></a>
              <pre class="programlisting">
<span class="nt">&lt;CsoundSynthesizer&gt;</span>
<span class="nt">&lt;CsOptions&gt;</span>
<span class="c1">; Select audio/midi flags here according to platform</span>
<span class="c1">; Audio out   Audio in</span>
-odac           -iadc    <span class="c1">;;;RT audio I/O</span>
<span class="c1">; For Non-realtime ouput leave only the line below:</span>
<span class="c1">; -o printks.wav -W ;;; for file output any platform</span>
<span class="nt">&lt;/CsOptions&gt;</span>
<span class="nt">&lt;CsInstruments&gt;</span>

<span class="c1">; Initialize the global variables.</span>
<span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span>
<span class="vg">kr</span> <span class="o">=</span> <span class="mi">44100</span>
<span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">1</span>
<span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">1</span>

<span class="c1">; Instrument #1.</span>
<span class="kd">instr</span> <span class="nf">1</span>
  <span class="c1">; Change a value linearly from 0 to 100,</span>
  <span class="c1">; over the period defined by p3.</span>
  k<span class="n">up</span> <span class="nb">line</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">p3</span><span class="p">,</span> <span class="mi">100</span>
  <span class="c1">; Change a value linearly from 30 to 10, </span>
  <span class="c1">; over the period defined by p3.</span>
  k<span class="n">down</span> <span class="nb">line</span> <span class="mi">30</span><span class="p">,</span> <span class="nb">p3</span><span class="p">,</span> <span class="mi">10</span>

  <span class="c1">; Print the value of kup and kdown, once per second.</span>
  <span class="nb">printks</span> <span class="s">"kup = %f, kdown = %f</span><span class="se">\\</span><span class="s">n"</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> k<span class="n">up</span><span class="p">,</span> k<span class="n">down</span>
<span class="kd">endin</span>


<span class="nt">&lt;/CsInstruments&gt;</span>
<span class="nt">&lt;CsScore&gt;</span>

<span class="c1">; Play Instrument #1 for 5 seconds.</span>
<span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">5</span>
<span class="nb">e</span>


<span class="nt">&lt;/CsScore&gt;</span>
<span class="nt">&lt;/CsoundSynthesizer&gt;</span>
</pre>
            </div>
          </div>
        </div>
        <p><br class="example-break" />

      Its output should include lines like this:

      </p>
        <pre class="screen">
kup = 0.000000, kdown = 30.000000
kup = 20.010843, kdown = 25.962524
kup = 40.029991, kdown = 21.925049
kup = 60.049141, kdown = 17.887573
kup = 79.933266, kdown = 13.872493
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901812152"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="printk2.html" title="printk2"><em class="citetitle">printk2</em></a> and 
      <a class="link" href="printk.html" title="printk"><em class="citetitle">printk</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idm281472901809032"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Robin Whittle</td>
          </tr>
          <tr>
            <td>Australia</td>
          </tr>
          <tr>
            <td>May 1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>Example written by Kevin Conder.</p>
        <p>Thanks goes to Luis Jure for pointing out a mistake with the <span class="emphasis"><em>itime</em></span> parameter.</p>
        <p>Thanks to Matt Ingalls, updated the documentation for version 4.23.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="printk.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="printks2.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">printk </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> printks2</td>
        </tr>
      </table>
    </div>
  </body>
</html>