Skip to content

filebit

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 stereoJungle.wav.

Example of the filebit opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-n   ; no sound
; For Non-realtime ouput leave only the line below:
; -o filebit.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1

ibits filebit "stereoJungle.wav"
prints  "\nbit depth = %d bit\n\n", ibits

endin


</CsInstruments>
<CsScore>
i 1 0 0
e
</CsScore>
</CsoundSynthesizer>
The output should include a line like this:

bit depth = 16 bit

See also

Sound File Queries

Credits

Author: Victor Lazzarini
July 1999

New in Csound version 5.11