println

printks — Prints at k-rate using a printf() style syntax, appends a new line

Description

Prints at k-rate using a printf() style syntax. This opcode is similar to printsk, the only difference being that println appends a new line to each message

Syntax

println "string", [, xval1] [, xval2] [...]

Initialization

"string" -- the text string to be printed. Can be up to 8192 characters and must be in double quotes.

Performance

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.

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.

For more information about printf() formatting, consult any C language documentation.

Examples

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

Example 789. Example of the println 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>


See Also

printks, printf, printsk

Credits

By: Eduardo Moguillansky 2020

New plugin in version 6.15