dumpk2

dumpk2 — Periodically writes two orchestra control-signal values to an external file.

Description

Periodically writes two orchestra control-signal values to a named external file in a specific format.

Syntax

dumpk2 ksig1, ksig2, 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

ksig1, ksig2 -- control-rate signals.

This opcode allows two generated control signal values 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 dumpk2 opcodes in an instrument or orchestra but each must write to a different file.

Examples

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

Example 212. Example of the dumpk2 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
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o dumpk2.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 two control signals to a file
kfreq     randh     100, 1, 2, 1, 500 ;generates one random number between 400 and 600 per second
kdb       randh     12, 1, 2, 1, -12 ;amplitudes in dB between -24 and 0
          dumpk2    kfreq, kdb, "dumpk2.txt", 8, 1 ;writes the control signals
          prints    "WRITING:\n"
          printks   "kfreq = %f, kdb = %f\n", 1, kfreq, kdb  ;prints them
endin

instr 2 ;reads the file written by instr 1
kf,kdb    readk2    "dumpk2.txt", 8, 1
          prints    "READING:\n"
          printks   "kfreq = %f, kdb = %f\n", 1, kf, kdb  ;prints again
kdb       lineto    kdb, .1 ;smoothing amp transition
aout      poscil    ampdb(kdb), kf, giSine
          outs      aout, aout
endin

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


The output should include lines like these:

kfreq = 429.202551, kdb = -20.495694
kfreq = 429.202551, kdb = -20.495694
kfreq = 407.275258, kdb = -23.123776
kfreq = 475.264472, kdb = -9.300846
kfreq = 569.979181, kdb = -7.315527
kfreq = 440.103457, kdb = -0.058331

kfreq = 429.202600, kdb = -20.495700
kfreq = 429.202600, kdb = -20.495700
kfreq = 407.275300, kdb = -23.123800
kfreq = 475.264500, kdb = -9.300800
kfreq = 569.979200, kdb = -7.315500
kfreq = 440.103500, kdb = -0.058300
      

See Also

dumpk, dumpk3, dumpk4, readk, readk2, readk3, readk4

Credits

By: John ffitch and Barry Vercoe

1999 or earlier