| 1 | |
| 2 | <refentry id="printks2"> |
| 3 | <indexterm id="IndexPrintks2"><primary>printks2</primary></indexterm> |
| 4 | <refentryinfo><title>Signal I/O:Printing and Display</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>printks2</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>printks2</refname> |
| 13 | <refpurpose> |
| 14 | Prints a new value every time a control variable changes using a |
| 15 | printf() style syntax. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | Prints a new value every time a control variable changes using a |
| 23 | printf() style syntax. |
| 24 | </para> |
| 25 | </refsect1> |
| 26 | |
| 27 | <refsect1> |
| 28 | <title>Syntax</title> |
| 29 | <synopsis><command>printks2</command> "string", kval</synopsis> |
| 30 | </refsect1> |
| 31 | |
| 32 | <refsect1> |
| 33 | <title>Initialization</title> |
| 34 | <para> |
| 35 | <emphasis>"string"</emphasis> -- the text string to be |
| 36 | used as a format. |
| 37 | </para> |
| 38 | </refsect1> |
| 39 | |
| 40 | <refsect1> |
| 41 | <title>Performance</title> |
| 42 | <para> |
| 43 | <emphasis>kval</emphasis> -- signal to be printed. The style of |
| 44 | printing is specified in |
| 45 | <emphasis><quote>string</quote></emphasis> with the standard C |
| 46 | value specifier (%f, %d, etc.). |
| 47 | </para> |
| 48 | |
| 49 | </refsect1> |
| 50 | |
| 51 | <refsect1> |
| 52 | <title>Print Output Formatting</title> |
| 53 | <para> |
| 54 | All standard C language printf() control characters may be used. For example, if <emphasis>kval1</emphasis> = 153.26789 then some common formatting options are: |
| 55 | |
| 56 | <orderedlist> |
| 57 | <listitem><para>%f prints with full precision: 153.26789</para></listitem> |
| 58 | <listitem><para>%5.2f prints: 153.26</para></listitem> |
| 59 | <listitem><para>%d prints integers-only: 153</para></listitem> |
| 60 | <listitem><para>%c treats <emphasis>kval1</emphasis> as an ascii character code. </para></listitem> |
| 61 | </orderedlist> |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | In addition to all the printf() codes, printks2 supports these useful character codes: |
| 66 | |
| 67 | <informaltable frame="all"> |
| 68 | <tgroup cols="2" colsep="1" rowsep="1"> |
| 69 | <thead> |
| 70 | <row> |
| 71 | <entry>printks2 Code</entry> |
| 72 | <entry>Character Code</entry> |
| 73 | </row> |
| 74 | </thead> |
| 75 | |
| 76 | <tbody> |
| 77 | <row> |
| 78 | <entry>\\r, \\R, %r, or %R</entry> |
| 79 | <entry>return character (\r)</entry> |
| 80 | </row> |
| 81 | |
| 82 | <row> |
| 83 | <entry>\\n, \\N, %n, %N</entry> |
| 84 | <entry>newline character (\n)</entry> |
| 85 | </row> |
| 86 | |
| 87 | <row> |
| 88 | <entry>\\t, \\T, %t, or %T</entry> |
| 89 | <entry>tab character (\t)</entry> |
| 90 | </row> |
| 91 | |
| 92 | <row> |
| 93 | <entry>%!</entry> |
| 94 | <entry>semicolon character (;) This was needed because a <quote>;</quote> is interpreted as an comment.</entry> |
| 95 | </row> |
| 96 | |
| 97 | <row> |
| 98 | <entry>^</entry> |
| 99 | <entry>escape character (0x1B)</entry> |
| 100 | </row> |
| 101 | |
| 102 | <row> |
| 103 | <entry>^ ^</entry> |
| 104 | <entry>caret character (^)</entry> |
| 105 | </row> |
| 106 | |
| 107 | <row> |
| 108 | <entry>˜</entry> |
| 109 | <entry>ESC[ (escape+[ is the escape sequence for ANSI |
| 110 | consoles)</entry> |
| 111 | </row> |
| 112 | |
| 113 | <row> |
| 114 | <entry>˜˜</entry> |
| 115 | <entry>tilde (˜)</entry> |
| 116 | </row> |
| 117 | </tbody> |
| 118 | </tgroup> |
| 119 | </informaltable> |
| 120 | </para> |
| 121 | |
| 122 | <para> |
| 123 | For more information about printf() formatting, consult any C |
| 124 | language documentation. |
| 125 | </para> |
| 126 | |
| 127 | </refsect1> |
| 128 | |
| 129 | <refsect1> |
| 130 | <title>Examples</title> |
| 131 | <para> |
| 132 | Here is an example of the printks2 opcode. It uses the file <ulink url="examples/printks2.csd"><citetitle>printks2.csd</citetitle></ulink>. |
| 133 | |
| 134 | <example> |
| 135 | <title>Example of the printks2 opcode.</title> |
| 136 | |
| 137 | |
| 138 | |
| 139 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 140 | <xi:include href="examples-xml/printks2.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 141 | </example> |
| 142 | </para> |
| 143 | </refsect1> |
| 144 | |
| 145 | <refsect1> |
| 146 | <title>See also</title> |
| 147 | <para><link linkend="SigioPdisplay"><citetitle>Printing and Display</citetitle></link></para> |
| 148 | </refsect1> |
| 149 | |
| 150 | <refsect1> |
| 151 | <title>Credits</title> |
| 152 | <para> |
| 153 | <simplelist> |
| 154 | <member>Author: &namejohn;</member> |
| 155 | <member>Bath, UK</member> |
| 156 | <member>Mar 2014</member> |
| 157 | </simplelist> |
| 158 | </para> |
| 159 | <para>New in Csound version 6.03</para> |
| 160 | </refsect1> |
| 161 | </refentry> |