The Alternative Csound Reference Manual
Previous |  | Next

# printk

printk -- Prints one k-rate value at specified intervals.

## Description

Prints one k-rate value at specified intervals.

## Syntax

printk itime, kval [, ispace]

## Initialization

itime -- time in seconds between printings.

ispace (optional, default=0) -- number of spaces to insert before printing. (default: 0, max: 130)

## Performance

kval -- The k-rate values to be printed.

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.

This opcode can be run on every k-cycle it is 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.

## Examples

Here is an example of the printk opcode. It uses the files printk.orc and printk.sco.

Example 1. Example of the printk opcode.

    /* printk.orc */
    ; 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, once per second.
      printk 1, kval
    endin
    /* printk.orc */

    /* printk.sco */
    ; Play Instrument #1 for 5 seconds.
    i 1 0 5
    e
    /* printk.sco */

Its output should include lines like this:

     i   1 time     0.00002:     0.00000
     i   1 time     1.00002:    20.01084
     i   1 time     2.00002:    40.02999
     i   1 time     3.00002:    60.04914
     i   1 time     4.00002:    79.93327

## See Also

printk2 and printks

## Credits

Author: Robin Whittle
Australia
May 1997

Example written by Kevin Conder.

Thanks goes to Luis Jure for pointing out a mistake wit the itime parameter.

Previous | Home | Next
print | Up | printk2