The Alternative Csound Reference Manual
Previous |  | Next

# fout

fout -- Outputs a-rate signals to an arbitrary number of channels.

## Description

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

## Syntax

fout ifilename, iformat, aout1 [, aout2, aout3,...,aoutN]

## Initialization

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

iformat -- a flag to choose output file format:

- 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 format. The default header type is the IRCAM format. If the user chooses the AIFF format (using the -A flag), the header format will be a AIFF type. If the user chooses the WAV format (using the -W flag), the header format will be a WAV type.

## Performance

aout1,... aoutN -- signals to be written to the file

fout (file output) writes samples of audio signals to a file with any number of channels. Channel number depends by the number of aoutN variables (i.e. a mono signal with only an a-rate argument, a stereo signal with two a-rate arguments etc.) Maximum number of channels is fixed to 64. Multiple fout opcodes can be present in the same instrument, referring to different files.

Notice that, unlike out, outs and outq, fout does not zero the audio variable so you must zero it after calling it. If polyphony is to be used, you can use vincr and clear opcodes for this task.

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 a simple example of the fout opcode. It uses the files fout.orc and fout.sco.

Example 1. Example of the fout opcode.

    /* fout.orc */
    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      iamp = 10000
      icps = 440
      iphs = 0

      ; Create an audio signal.
      asig oscils iamp, icps, iphs

      ; Write the audio signal to a headerless audio file
      ; called "fout.raw".
      fout "fout.raw", 1, asig
    endin
    /* fout.orc */

    /* fout.sco */
    ; Play Instrument #1 for 2 seconds.
    i 1 0 2
    e
    /* fout.sco */

Here is an example of the fout opcode with a polyphonic score. It uses the files fout_poly.orc, fout_poly.sco and beats.wav.

Example 2. Example of the fout opcode with a polyphonic score.

    /* fout_poly.orc */
    ; Initialize the global variables.
    sr = 44100
    kr = 44100
    ksmps = 1
    nchnls = 1

    ; Initialize the global audio signal.
    gaudio init 0

    ; Instrument #1 - Play an audio file.
    instr 1
      ; Generate an audio signal using
      ; the audio file "beats.wav".
      asig soundin "beats.wav"

      ; Add this audio signal to the global one.
      vincr gaudio, asig
    endin

    ; Instrument #2 - Create a basic tone.
    instr 2
      iamp = 5000
      icps = 440
      iphs = 0

      ; Create an audio signal.
      asig oscils iamp, icps, iphs

      ; Add this audio signal to the global one.
      vincr gaudio, asig
    endin

    ; Instrument #99 - Save the global signal to a file.
    instr 99
      ; Write the global audio signal to a headerless
      ; audio file called "fout_poly.raw".
      fout "fout_poly.raw", 1, gaudio

      ; Clear the global audio signal, preparing it
      ; for the next round.
      clear gaudio
    endin
    /* fout_poly.orc */

    /* fout_poly.sco */
    ; Play Instrument #1 for two seconds.
    i 1 0 2

    ; Play Instrument #2 every quarter-second.
    i 2 0.00 0.1
    i 2 0.25 0.1
    i 2 0.50 0.1
    i 2 0.75 0.1
    i 2 1.00 0.1
    i 2 1.25 0.1
    i 2 1.50 0.1
    i 2 1.75 0.1

    ; Make sure the global instrument, #99, is running
    ; during the entire performance (2 seconds).
    i 99 0 2
    e
    /* fout_poly.sco */

## See Also

fiopen, fouti, foutir, foutk

## Credits

Author: Gabriel Maldonado
Italy
1999

The simple example was written by Kevin Conder.

New in Csound version 3.56

October 2002. Added a note from Richard Dobson.

Previous | Home | Next
foscili | Up | fouti