printks2 — Prints a new value every time a control variable changes using a printf() style syntax.
kval -- signal to be printed. The style of printing is specified in “string” with the standard C value specifier (%f, %d, etc.).
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, printks2 supports these useful character codes:
printks2 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.
Here is an example of the printks2 opcode. Play printks2.csd
Example 788. Example of the printks2 opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform ; Audio out Audio in ; For Non-realtime ouput leave only the line below: ; -o printk.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; 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. kval line 0, p3, 100 ; Print the value of kval when it changes. printks2 "value now %f\n", int(kval) endin </CsInstruments> <CsScore> ; Play Instrument #1 for 5 seconds. i 1 0 5 e </CsScore> </CsoundSynthesizer>