| 1 | |
| 2 | <refentry id="printf"> |
| 3 | <indexterm id="Indexprintf_i"><primary>printf_i</primary></indexterm> |
| 4 | |
| 5 | <indexterm id="Indexprintf"><primary>printf</primary></indexterm> |
| 6 | <refentryinfo><title>Signal I/O:Printing and Display</title></refentryinfo> |
| 7 | <refmeta> |
| 8 | <refentrytitle>printf</refentrytitle> |
| 9 | </refmeta> |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>printf</refname> |
| 13 | <refpurpose> |
| 14 | printf-style formatted output |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | <command>printf</command> and <command>printf_i</command> write |
| 22 | formatted output, similarly to the C function |
| 23 | printf(). <command>printf_i</command> runs at i-time only, while |
| 24 | <command>printf</command> runs both at initialization and |
| 25 | performance time. |
| 26 | </para> |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Syntax</title> |
| 31 | <synopsis><command>printf_i</command> Sfmt, itrig, [iarg1[, iarg2[, ... ]]]</synopsis> |
| 32 | <synopsis><command>printf</command> Sfmt, ktrig, [xarg1[, xarg2[, ... ]]]</synopsis> |
| 33 | </refsect1> |
| 34 | |
| 35 | <refsect1> |
| 36 | <title>Initialization</title> |
| 37 | <para> |
| 38 | <emphasis>Sfmt</emphasis> -- format string, has the same format |
| 39 | as in printf() and other similar C functions, except length |
| 40 | modifiers (l, ll, h, etc.) are not supported. The following |
| 41 | conversion specifiers are allowed: |
| 42 | <itemizedlist> |
| 43 | <listitem> |
| 44 | <para>d, i, o, u, x, X, e, E, f, F, g, G, c, s</para> |
| 45 | </listitem> |
| 46 | </itemizedlist> |
| 47 | </para> |
| 48 | <para> |
| 49 | <emphasis>iarg1, iarg2, ...</emphasis> -- input arguments |
| 50 | (max. 30) for format. Integer formats like %d round the input |
| 51 | values to the nearest integer. |
| 52 | </para> |
| 53 | <para> |
| 54 | <emphasis>itrig</emphasis> -- if greater than zero the opcode |
| 55 | performs the printing; otherwise it is an null operation. |
| 56 | </para> |
| 57 | |
| 58 | </refsect1> |
| 59 | |
| 60 | <refsect1> |
| 61 | <title>Performance</title> |
| 62 | <para> |
| 63 | <emphasis>ktrig</emphasis> -- if greater than zero and different |
| 64 | from the value on the previous control cycle the opcode |
| 65 | performs the requested printing. Initially this previous value is |
| 66 | taken as zero. |
| 67 | </para> |
| 68 | <para> |
| 69 | <emphasis>xarg1, xarg2, ...</emphasis> -- input arguments |
| 70 | (max. 30) for format. Integer formats like %d round the input |
| 71 | values to the nearest integer. Note that only k-rate and i-rate arguments are valid (no a-rate printing) |
| 72 | </para> |
| 73 | </refsect1> |
| 74 | <refsect1> |
| 75 | <title>Examples</title> |
| 76 | <para> |
| 77 | Here is an example of the printf opcode. It uses the file <ulink url="examples/printf.csd"><citetitle>printf.csd</citetitle></ulink>. |
| 78 | <example> |
| 79 | <title>Example of the printf opcode.</title> |
| 80 | <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> |
| 81 | <xi:include href="examples-xml/printf.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 82 | </example> |
| 83 | </para> |
| 84 | <para> |
| 85 | The example will produce the following output: |
| 86 | <screen> |
| 87 | Audiofile 'frox.wav' does not exist! |
| 88 | </screen> |
| 89 | </para> |
| 90 | </refsect1> |
| 91 | |
| 92 | <refsect1> |
| 93 | <title>See also</title> |
| 94 | <para><link linkend="SigioPdisplay"><citetitle>Printing and Display</citetitle></link></para> |
| 95 | <para> More information about printf: <ulink url="http://www.cplusplus.com/reference/clibrary/cstdio/printf/"><citetitle>http://www.cplusplus.com/reference/clibrary/cstdio/printf/</citetitle></ulink></para> |
| 96 | </refsect1> |
| 97 | |
| 98 | <refsect1> |
| 99 | <title>Credits</title> |
| 100 | <para> |
| 101 | <simplelist> |
| 102 | <member>Author: Istvan Varga</member> |
| 103 | <member>2005</member> |
| 104 | </simplelist> |
| 105 | </para> |
| 106 | </refsect1> |
| 107 | </refentry> |