istring -- the text string to be printed. Can be up to 130 characters and must be in double quotes.
itime -- time in seconds between printings.
kval, kval1, kval2, kval3, kval4 -- The k-rate values to be printed. These are specified in "txtstring" with the standard C value specifier %f, in the order given. Use 0 for those which are not used.
printks prints numbers and text, with up to four printable numbers - which can be i- 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. Three more format specifers may be used - they access kval2, kval3 and kval4.
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.
Standard C language printf() control characters may be used, but must be prefaced with an additional backslash:
\\n or \\N Newline
\\t or \\T Tab
The standard C lanuage %f format is used to print kval1, kval2, kval3, and kval4. For example:
%f prints with full precision: 123.456789
%6.2f prints 1234.56
%5.0p prints 12345
Here is an example of the printks opcode. It uses the files printks.orc and printks.sco.
Example 1. Example of the printks opcode.
/* printks.orc */
/* Written by Kevin Conder */
; Initialize the global variables.
sr = 44100
kr = 44100
ksmps = 1
nchnls = 1
; Instrument #1.
instr 1
; Change a value linearly from 0 to 100,
; over the period defined by p3.
kup line 0, p3, 100
; Change a value linearly from 30 to 10,
; over the period defined by p3.
kdown line 30, p3, 10
; Print the value of kup and kdown, once per second.
printks "kup = %f, kdown = %f\\n", 1, kup, kdown
endin
/* printks.orc */
/* printks.sco */
/* Written by Kevin Conder */
; Play Instrument #1 for 5 seconds.
i 1 0 5
e
/* printks.sco */
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