filebit
Prev | Orchestra Opcodes and Operators | Next

## filebit

filebit — Returns the number of bits in each sample in a sound file.

## Description

Returns the number of bits in each sample in a sound file.

## Syntax

    ir filebit ifilcod [, iallowraw]

## Initialization

ifilcod -- sound file to be queried

iallowraw -- (Optional) Allow raw sound files (default=1)

## Performance

filebit returns the number of bits in each sample in the sound file ifilcod. In the case of floating point samples the value -1 is returned for floats and -2 for doubles. For non-PCM formats the value is negative, and based on libsndfile's format encoding.

## Examples

Here is an example of the filebit opcode. It uses the file filebit.csd, and mary.wav.

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

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Print out the number of channels in the
      ; audio file "mary.wav".
      ibits filebit "mary.wav"
      print ibits
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for 1 second.
    i 1 0 1
    e

    </CsScore>
    </CsoundSynthesizer>

The audio file “mary.wav” is in monoaural CD format, so filebit's output should include a line like this:

    instr 1:  ibits = 16.000

## See Also

filelen, filenchnls, filepeak, filesr

## Credits

Author: Victor Lazzarini
July 1999

Example written by John ffitch.

New in Csound version 5.11

Prev | Up | Next
ficlose | Home | filelen