ftaudio
Prev | Orchestra Opcodes and Operators | Next

## ftaudio

ftaudio — Write a previously-allocated table to an audio file.

## Description

Write a previously-allocated table to an audio file in a variety of formats.

## Syntax

    ians ftaudio ifn, "filename", iformat[, ibeg, iend]

    kans ftaudio ktrig, kfn, "filename", kformat [, isync, kbeg, kend]

## Initialization

ifn, kfn -- Number of table to write.

"filename" -- A quoted string containing the name of the file to save.

iformat, kformat -- Format of the file to save.

- -1 - format exactly as per global csound output format flags (-A, -W, --format=..., etc).

- 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 with a header. The header type depends on the render (-o) format. For example, if the user chooses the AIFF format (using the -A flag), the header format will be AIFF type.

- 3 - u-law samples with a header (see iformat=2).

- 4 - 16-bit integers with a header (see iformat=2).

- 5 - 32-bit integers with a header (see iformat=2).

- 6 - 32-bit floats with a header (see iformat=2).

- 7 - 8-bit unsigned integers with a header (see iformat=2).

- 8 - 24-bit integers with a header (see iformat=2).

- 9 - 64-bit floats with a header (see iformat=2).

- 50 - ogg-vorbis format.

In addition Csound allows for explicitly selecting a particular header type by specifying the format as 10 * fileType + sampleFormat, where fileType may be 1 for WAV, 2 for AIFF, 3 for raw (headerless) files, and 4 for IRCAM; sampleFormat is one of the above values in the range 0 to 9, except sample format 0 is taken from the command line (-o), format 1 is 8-bit signed integers, and format 2 is a-law. So, for example, iformat=25 means 32-bit integers with AIFF header.

isync -- if zero the k-rate version waits for the write to finish. If non-zero (default) the writing of data is delegated to a separate thread which then allows Csound to continue with the rendering.

ibeg,iend,kbeg,kend -- gives limits to start and end of section of the table to write, in samples. Default values of zero means from start to end.

ians, kans -- returns zero if the operation fails or 1 on success. In the asynchronous mode this is updated when the writing finishes, until when it has the value -1

## Performance

ktrig -- the k-rate version only happens on a k-cycle when ktrig is non-zero.

## Examples

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

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

    ; Initialize the global variables.
    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

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

    instr 1
         ktrig init    1
         asig  poscil3 .5, 880, giSine
         kans  ftaudio ktrig, 100, "k_ftaudio.wav", 15, 1
         ktrig =       0
               outs    asig, asig
    endin

    instr 2
         ians  ftaudio 100, "i_ftaudio.wav", 15, p4, p5
               turnoff
    endin

    </CsInstruments>
    <CsScore>
    f100 0 0 -1 "drumsMlp.wav" 0 0 0
    i 1 0 2
    i 2 0 1 11025 33075; 0.5 seconds cut
    e
    </CsScore>
    </CsoundSynthesizer>

## See also

Read/Write Operations

## Credits

Author: John ffitch

Example written by John ffitch.

New in version 6.12

Limit to range bnew in 6.13

Prev | Up | Next
freeverb | Home | ftchnls