| 1 | |
| 2 | <refentry id="sprintfk"> |
| 3 | <indexterm id="Indexsprintfk"><primary>sprintfk</primary></indexterm> |
| 4 | <refentryinfo><title>Strings:Manipulation</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>sprintfk</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>sprintfk</refname> |
| 11 | <refpurpose> |
| 12 | printf-style formatted output to a string variable at k-rate. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | <emphasis>sprintfk</emphasis> writes printf-style formatted output to a string variable, similarly to the C function sprintf(). <emphasis>sprintfk</emphasis> runs both at initialization and performance time. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>Sdst <command>sprintfk</command> Sfmt, xarg1[, xarg2[, ... ]]</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Initialization</title> |
| 30 | <para> |
| 31 | <emphasis>Sfmt</emphasis> -- format string, has the same format as in printf() and other similar C functions, except length modifiers (l, ll, h, etc.) are not supported. The following conversion specifiers are allowed: |
| 32 | <itemizedlist> |
| 33 | <listitem> |
| 34 | <para>d, i, o, u, x, X, e, E, f, F, g, G, c, s</para> |
| 35 | </listitem> |
| 36 | </itemizedlist> |
| 37 | </para> |
| 38 | |
| 39 | <para> |
| 40 | <emphasis>xarg1, xarg2, ...</emphasis> -- input arguments (max. 30) for format, should be i-rate for all conversion specifiers except %s, which requires a string argument. sprintfk also allows k-rate number arguments, but these should still be valid at init time as well (unless sprintfk is skipped with igoto). Integer formats like %d round the input values to the nearest integer. |
| 41 | </para> |
| 42 | </refsect1> |
| 43 | |
| 44 | <refsect1> |
| 45 | <title>Performance</title> |
| 46 | <para> |
| 47 | <emphasis>Sdst</emphasis> -- output string variable |
| 48 | </para> |
| 49 | </refsect1> |
| 50 | |
| 51 | <refsect1> |
| 52 | <title>Examples</title> |
| 53 | <para> |
| 54 | Here is an example of the sprintfk opcode. It uses the file <ulink url="examples/sprintfk.csd"><citetitle>sprintfk.csd</citetitle></ulink>. |
| 55 | <example> |
| 56 | <title>Example of the sprintfk opcode.</title> |
| 57 | <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> |
| 58 | <xi:include href="examples-xml/sprintfk.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 59 | </example> |
| 60 | Its output should include lines like this: |
| 61 | <screen> |
| 62 | 1 + 1 = 2 |
| 63 | 1 + 1 + 1 = 3 |
| 64 | 1 + 1 + 1 + 1 = 4 |
| 65 | 1 + 1 + 1 + 1 + 1 = 5 |
| 66 | 1 + 1 + 1 + 1 + 1 + 1 = 6 |
| 67 | 1 + 1 + 1 + 1 + 1 + 1 + 1 = 7 |
| 68 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8 |
| 69 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 9 |
| 70 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 10 |
| 71 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 11 |
| 72 | 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 12</screen> |
| 73 | </para> |
| 74 | </refsect1> |
| 75 | |
| 76 | <refsect1> |
| 77 | <title>See Also</title> |
| 78 | <para><link linkend="stringmanipulate"><citetitle></citetitle>String Manipulation Opcodes</link></para> |
| 79 | </refsect1> |
| 80 | |
| 81 | <refsect1> |
| 82 | <title>Credits</title> |
| 83 | <para> |
| 84 | <simplelist> |
| 85 | <member>Author: Istvan Varga</member> |
| 86 | <member>2005</member> |
| 87 | <member>Example by Jonathan Murphy</member> |
| 88 | </simplelist> |
| 89 | </para> |
| 90 | </refsect1> |
| 91 | </refentry> |