0dbfs
Prev | Orchestra Opcodes and Operators | Next

## 0dbfs

0dbfs — Sets the value of 0 decibels using full scale amplitude.

## Description

Sets the value of 0 decibels using full scale amplitude.

## Syntax

    0dbfs = iarg

    0dbfs

## Initialization

iarg -- the value of 0 decibels using full scale amplitude.

## Performance

The default is 32767, so all existing orcs should work.

Amplitude values in Csound are always relative to a "0dbfs" value representing the peak available amplitude before clipping. In the original Csound, this value was always 32767, corresponding to the bipolar range of a 16bit soundfile or 16bit AD/DA codec. This remains the default peak amplitude for Csound, for backward compatibility. The 0dbfs value enables Csound to produce appropriately scaled values to whatever output format is being used, whether 16bit integer, 24bit integer, 32bit floats, or even 32bit integers.

OdBFS can be defined in the header, to set the amplitude reference Csound will use, but it can also be used as a varible inside instruments like this:

    ipeak = 0dbfs

    asig oscil 0dbfs, freq, 1
         out   asig * 0.3 * 0dbfs

The purpose of the 0dbfs opcode is for people to start to code 0dbfs-relatively (and use the ampdbfs() opcodes a lot more!), rather than use explicit sample values. Using 0dbfs=1 is in accordance to industry practice, as ranges from -1 to 1 are used in most commercial plugin formats and in most other synthesis systems like Pure Data.

Floats written to a file, when 0dbfs = 1, will in effect go through no range translation at all. So the numbers in the file are exactly what the orc says they are.

For more details on amplitude values in Csound, see the section Amplitude values in Csound

## Example

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

Example 36. Example of the 0dbfs 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    No messages
    -odac           -iadc     -d     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o 0dbfs.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    ksmps = 10
    nchnls = 2

    ; Set the 0dbfs to 1.
    0dbfs = 1

    instr 1  ; from linear amplitude (0-1 range)
    print p4
    a1 oscil p4, 440, 1
    outs a1, a1
    endin

    instr 2  ; from linear amplitude (0-32767 range)
    iamp = p4 / 32767
    print iamp
    a1 oscil iamp, 440, 1
    outs a1, a1
    endin

    instr 3  ; from dB FS
    iamp = ampdbfs(p4)
    print iamp
    a1 oscil iamp, 440, 1
    outs a1, a1
    endin

    </CsInstruments>
    <CsScore>

    ; Table #1, a sine wave.
    f 1 0 16384 10 1

    i 1 0 1   1
    i 1 + 1   0.5
    i 1 + 1   0.1
    s
    i 2 0 1   32767
    i 2 + 1   [32767/2]
    i 2 + 1   [3276.7]
    s
    i 3 0 1   0
    i 3 + 1   -6
    i 3 + 1   -20
    e

    </CsScore>
    </CsoundSynthesizer>

## See also

ampdbfs()

## Credits

Author: Richard Dobson
May 2002

New in version 4.10

Prev | Up | Next
! | Home | A4