printks — Prints at k-rate using a printf() style syntax.
Prints at k-rate using a printf() style syntax. This opcode prints at every cycle, possibly multiple times per cycle. Used inside an if-block it can behave like printf, printks (when used together with metro) or printks2 (when used with changed).
"string" -- the text string to be printed. Can be up to 8192 characters and must be in double quotes.
xval1, xval2, ... (optional) -- The k-rate values to be printed. These are specified in “string” with the standard C value specifier (%f, %d, %s etc.) in the order given.
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.
For more information about printf() formatting, consult any C language documentation.
Here is an example of the printsk opcode. Play printsk.csd
Example 791. Example of the printsk opcode.
<CsoundSynthesizer> <CsOptions> </CsOptions> <CsInstruments> sr = 44100 ksmps = 64 nchnls = 1 instr 1 ; printsk is executed at k-time, possibly multiples times per cycle. k0 = 0 while k0 < 20 do if k0 % 2 == 0 then printsk "k0 = %d\n", k0 endif k0 += 1 od endin instr 2 ; println is similar to printsk but appends a new line k0 = 0 while k0 < 20 do if k0 % 2 == 0 then println "k0 = %d", k0 endif k0 += 1 od endin </CsInstruments> <CsScore> i 1 0 0.1 i 2 0.1 0.1 e </CsScore> </CsoundSynthesizer>