printks2
Prev | Orchestra Opcodes and Operators | Next

## printks2

printks2 — Prints a new value every time a control variable changes using a printf() style syntax.

## Description

Prints a new value every time a control variable changes using a printf() style syntax.

## Syntax

    printks2 "string", kval

## Initialization

"string" -- the text string to be used as a format.

## Performance

kval -- signal to be printed. The style of printing is specified in “string” with the standard C value specifier (%f, %d, etc.).

## 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:

1. %f prints with full precision: 153.26789

2. %5.2f prints: 153.26

3. %d prints integers-only: 153

4. %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.

## Examples

Here is an example of the printks2 opcode. It uses the file printks2.csd.

Example 785. 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>

## See Also

printk2 and printk2 and printk

## Credits

Author: John ffitch
Bath, UK
Mar 2014

New in Csound version 6.03

Prev | Up | Next
printks | Home | println