<?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>printks2</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="printks.html" title="printks" /> <link rel="next" href="prints.html" title="prints" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">printks2</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="printks.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="prints.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="printks2"></a> <div class="titlepage"></div> <a id="IndexPrintks2" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">printks2</span> </h2> <p>printks2 — Prints a new value every time a control variable changes using a printf() style syntax. </p> </div> <div class="refsect1"> <a id="idm281472901781912"></a> <h2>Description</h2> <p> Prints a new value every time a control variable changes using a printf() style syntax. </p> </div> <div class="refsect1"> <a id="idm281472901738072"></a> <h2>Syntax</h2> <pre class="synopsis"><span class="command"><strong>printks2</strong></span> "string", kval</pre> </div> <div class="refsect1"> <a id="idm281472901735992"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>"string"</em></span> -- the text string to be used as a format. </p> </div> <div class="refsect1"> <a id="idm281472901734248"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kval</em></span> -- signal to be printed. The style of printing is 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.). </p> </div> <div class="refsect1"> <a id="idm281472901731752"></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, printks2 supports these useful character codes: </p> <div class="informaltable"> <table class="informaltable" border="1"> <colgroup> <col /> <col /> </colgroup> <thead> <tr> <th>printks2 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> <div class="refsect1"> <a id="idm281472901710712"></a> <h2>Examples</h2> <p> Here is an example of the printks2 opcode. It uses the file <a class="ulink" href="examples/printks2.csd" target="_top"><em class="citetitle">printks2.csd</em></a>. </p> <div class="example"> <a id="idm281472901708936"></a> <p class="title"> <strong>Example 721. Example of the printks2 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="idm281472722569608"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> <span class="c1">; Audio out Audio in</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o printk.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></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">val</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">; Print the value of kval when it changes.</span> <span class="nb">printks2</span> <span class="s">"value now %f</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span>k<span class="n">val</span><span class="p">)</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></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"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1"> <a id="idm281472901704712"></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="printks.html" title="printks"><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="idm281472901700648"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: John ffitch</td> </tr> <tr> <td>Bath, UK</td> </tr> <tr> <td>Mar 2014</td> </tr> </table> <p> </p> <p>New in Csound version 6.03</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="printks.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="prints.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">printks </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> prints</td> </tr> </table> </div> </body> </html>