printk — Prints one k-rate value at specified intervals.
itime -- time in seconds between printings.
ispace (optional, default=0) -- number of spaces to insert before printing. (default: 0, max: 130)
inamed (optional, default=0) -- if non zero print the name of the kvar as well as the value.
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.
Here is an example of the printk opcode. It uses the file printk.csd.
Example 786. Example of the printk 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 -odac -iadc ;;;RT audio I/O ; 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, once per second. printk 1, kval endin </CsInstruments> <CsScore> ; Play Instrument #1 for 5 seconds. i 1 0 5 e </CsScore> </CsoundSynthesizer>
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