Use Non-Frames Version Previous Page Next Page
Signal Input and Output: Printing and Display

printk, printks

          printk    kval, ispace[, itime]
          printks   "txtstring", itime, kval1, kval2, kval3, kval4

Description

These opcodes are intended to facilitate the debugging of orchestra code.

Initialization

ispace - number of spaces to insert before printing. (Max 130.)

itime - time in seconds between printings. (Default 1 second.)

"txtstring" - text to be printed. Can be up to 130 characters and must be in double quotes.

Performance

kvalx - 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.

printk prints one k-rate value on every k-cycle, every second or at intervals specified. First the instrument number is printed, then the absolute time in seconds, then a specified number of spaces, then the kval value. The variable number of spaces enables different values to be spaced out across the screen - so they are easier to view.

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.

Both these opcodes can be run on every k-cycle they are 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.

Print Output Formatting

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

Examples

The following:

  printks \"Volume = %6.2f Freq = %8.3f\n\", 0.1, kvol, kfreq, 0, 0

would print:

  Volume = 1234.56 Freq = 12345.678

The following:

  printks \"#x\\y = %6.2\n\", 0.1, kxy, 0, 0, 0

would print a tab character followed by:

  x\y = 1234.56

Author

Robin Whittle
Australia
May 1997


Use Non-Frames Version Previous Page Next Page
Signal Input and Output: Printing and Display