dumpk
Prev | Orchestra Opcodes and Operators | Next

## dumpk

dumpk — Periodically writes an orchestra control-signal value to an external file.

## Description

Periodically writes an orchestra control-signal value to a named external file in a specific format.

## Syntax

    dumpk  ksig, ifilname, iformat, iprd

## Initialization

ifilname -- character string (in double quotes, spaces permitted) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory

iformat -- specifies the output data format:

- 1 = 8-bit signed char(high order 8 bits of a 16-bit integer

- 4 = 16-bit short integers

- 5 = 32-bit long integers

- 6 = 32-bit floats

- 7 = ASCII long integers

- 8 = ASCII floats (2 decimal places)

Note that A-law and U-law output are not available, and that all formats except the last two are binary. The output file contains no header information.

iprd -- the period of ksig output in seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an output file sampled at the orchestra control rate.

## Performance

ksig -- a control-rate signal

This opcode allows a generated control signal value to be saved in a named external file. The file contains no self-defining header information. But it contains a regularly sampled time series, suitable for later input or analysis. There may be any number of dumpk opcodes in an instrument or orchestra but each must write to a different file.

## Examples

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

Example 210. Example of the dumpk 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 dumpk.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 20
    nchnls = 1

    ; By Andres Cabrera 2008

    instr 1
    ; Write fibonacci numbers to file "fibonacci.txt"
    ; as ascii long integers (mode 7), using the orchestra's
    ; control rate (iprd = 0)

    knumber init 0
    koldnumber init 1
    ktrans init 1
    ktrans = knumber
    knumber = knumber + koldnumber
    koldnumber = ktrans
    dumpk  knumber, "fibonacci.txt", 7, 0
    printk2 knumber
    endin

    </CsInstruments>
    <CsScore>

    ;Write to the file for 1 second. Since control rate is 20, 20 values will be written
     i 1 0 1

    </CsScore>
    </CsoundSynthesizer>

Here is another example of the dumpk opcode. It uses the file dumpk-2.csd.

Example 211. Example 2 of the dumpk opcode.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac      ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o dumpk-2.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    giSine ftgen 0, 0, 2^10, 10, 1

    instr 1 ;writes a control signal to a file
    kfreq randh  100, 1, 2, 1, 500 ;generates one random number between 400 and 600 per second
          dumpk  kfreq, "dumpk.txt", 8, 1 ;writes the control signal
          printk 1, kfreq 				 ;prints it
    endin

    instr 2 ;reads the file written by instr 1
    kfreq readk  "dumpk.txt", 8, 1
          printk 1, kfreq ;prints it
    aout  poscil .2, kfreq, giSine
          outs   aout, aout
    endin

    </CsInstruments>
    <CsScore>
    i 1 0 5
    i 2 5 5
    e
    </CsScore>
    </CsoundSynthesizer>

Its output should include lines like this:

    WARNING: Seeding from current time 683384022

     i   1 time     1.00033:   463.64510
     i   1 time     2.00000:   463.64510
     i   1 time     3.00000:   483.14200
     i   1 time     4.00000:   567.55973
     i   1 time     5.00000:   576.37060
     i   1 time     6.00000:   460.66550

     i   2 time     6.00033:   463.64510
     i   2 time     7.00000:   463.64510
     i   2 time     8.00000:   483.14200
     i   2 time     9.00000:   567.55970
     i   2 time    10.00000:   576.37060
     i   2 time    11.00000:   460.66550

## See Also

dumpk2, dumpk3, dumpk4, readk, readk2, readk3, readk4

## Credits

By: John ffitch and Barry Vercoe

1999 or earlier

Prev | Up | Next
dssilist | Home | dumpk2