printks Signal I/O:Printing and Display printks printks Prints at k-rate using a printf() style syntax. Description Prints at k-rate using a printf() style syntax. Syntax printks "string", itime [, kval1] [, kval2] [...] Initialization "string" -- the text string to be printed. Can be up to 8192 characters and must be in double quotes. itime -- time in seconds between printings. Performance kval1, kval2, ... (optional) -- The k-rate values to be printed. These are specified in string with the standard C value specifier (%f, %d, etc.) in the order given. In Csound version 4.23, you can use as many kval variables as you like. In versions prior to 4.23, you must specify 4 and only 4 kvals (using 0 for unused kvals). printks prints numbers and text which can be i-time or k-rate values. printks 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. A special mode of operation allows this printks to convert kval1 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. This opcode can be run on every k-cycle it is run in the instrument. To every accomplish this, set itime to 0. When itime is not 0, the opcode print on the first k-cycle it is called, and subsequently when every itime period has elapsed. The time cycles start from the time the opcode is initialized - typically the initialization of the instrument. Print Output Formatting All standard C language printf() control characters may be used. For example, if kval1 = 153.26789 then some common formatting options are: %f prints with full precision: 153.26789 %5.2f prints: 153.26 %d prints integers-only: 153 %c treats kval1 as an ascii character code. In addition to all the printf() codes, printks supports these useful character codes: printks Code Character Code \\r, \\R, %r, or %R return character (\r) \\n, \\N, %n, %N newline character (\n) \\t, \\T, %t, or %T tab character (\t) %! semicolon character (;) This was needed because a ; is interpreted as an comment. ^ escape character (0x1B) ^ ^ caret character (^) ˜ ESC[ (escape+[ is the escape sequence for ANSI consoles) ˜˜ tilde (˜) For more information about printf() formatting, consult any C language documentation. Note Prior to version 4.23, only the %f format code was supported. Examples Here is an example of the printks opcode. It uses the file printks.csd. Example of the printks opcode. See the sections Real-time Audio and Command Line Flags for more information on using command line flags. Its output should include lines like this: 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 See Also printk2 and printk Credits Author: Robin Whittle Australia May 1997 Example written by &namekevin;. Thanks goes to &nameluis; for pointing out a mistake with the itime parameter. Thanks to &namematt;, updated the documentation for version 4.23.