foutk

foutk — Outputs k-rate signals of an arbitrary number of channels to a specified file, in raw (headerless) format.

Description

foutk outputs N k-rate signals to a specified file of N channels.

Syntax

foutk ifilename, iformat, kout1 [, kout2, kout3,....,koutN]

Initialization

ifilename -- the output file's name (in double-quotes).

iformat -- a flag to choose output file format (note: Csound versions older than 5.0 may only support formats 0 and 1):

  • 0 - 32-bit floating point samples without header (binary PCM multichannel file)

  • 1 - 16-bit integers without header (binary PCM multichannel file)

  • 2 - 16-bit integers without header (binary PCM multichannel file)

  • 3 - u-law samples without header

  • 4 - 16-bit integers without header

  • 5 - 32-bit integers without header

  • 6 - 32-bit floats without header

  • 7 - 8-bit unsigned integers without header

  • 8 - 24-bit integers without header

  • 9 - 64-bit floats without header

Performance

kout1,...koutN -- control-rate signals to be written to the file. The expected range of the signals is determined by the selected sample format.

foutk operates in the same way as fout, but with k-rate signals. iformat can be set only in the range 0 to 9, or 0 to 1 with an old version of Csound.

Notice that fout and foutk can use either a string containing a file pathname, or a handle-number generated by fiopen. Whereas, with fouti and foutir, the target file can be only specified by means of a handle-number.

Examples

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

Example 374. Example of the foutk 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 real audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o foutk.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; by Stefano Cucchi - 2020

; Sing in your microphone for 10''
; Estimated pitch & amplitude are written on 2 files "amp" 6 "pitch"
; After 10'' a sawtooth is played with these values


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


instr 1	;use pitch

iupdte = 0.001
ilo = 6
ihi = 10
idbthresh = 10
ifrqs = 24
iconf = 10
istrt = 8

asig1, asig2 inch 1, 2
koct, kamp pitch asig1, iupdte, ilo, ihi, idbthresh, ifrqs, iconf, istrt ; pitch & amplitude tracking

kcps = cpsoct(koct)
kamp = kamp*0.00002
foutk "amp", 6, kamp ; write amplitude values on a file - 32-bit floats without header
foutk "pitch", 6, kcps ;  write pitch values on a file - 32-bit floats without header

endin

instr 2

kamp readk "amp", 6, p4 ; read amplitude values fro the file
kcps readk "pitch", 6, p4 ; read pitchvalues fro the file

kcps portk kcps, 0.008
asig oscili kamp, kcps*p5, 1 ; use amplitude & pitch to play a sawtooth
kdeclick linseg 0, 0.2, 1, p3 -0.4, 1, 0.2, 0

outs asig*kdeclick, asig*kdeclick

endin

</CsInstruments>
<CsScore>

f1 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111   ;sawtooth

i 1 0 10 
i 2 10 10 0.001 1 ;
e
</CsScore>
</CsoundSynthesizer>


To avoid zipper noise, by discontinuities produced from complex envelope tracking, a lowpass filter could be used, to smooth the estimated envelope.

See Also

fiopen, fout, fouti, foutir

Credits

Author: Gabriel Maldonado
Italy
1999

New in Csound version 3.56