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.

These calls should all work:

ipeak = 0dbfs

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

and so on.

As for documentation: the usage should be obvious - the main thing is for people to start to code 0dbfs-relatively (and use the ampdbfs() opcodes a lot more!), rather than use explicit sample values.

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.

[Note] BIG NB

All the main sample formats are supported, but I haven't got around to dealing with the char formats. Probably it's straight-forward...

I have tried to cover the main utils - adsyn, lpanal, etc. But there are bound to be things missing, sorry.

Some of the parsing code is a bit grungy because I have a variable with a leading digit!

Examples

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

Example 22. 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
kr = 4410
ksmps = 10
nchnls = 1

; Set the 0dbfs to the 16-bit maximum.
0dbfs = 32767

; Instrument #1.
instr 1
  ; Linearly increase the amplitude value "kamp" from 
  ; 0 to 1 over the duration defined by p3.
  kamp line 0, p3, 1

  ; Generate a basic tone using our amplitude value.
  a1 oscil kamp, 440, 1

  ; Multiply the basic tone (with its amplitude between 
  ; 0 and 1) by the full-scale 0dbfs value.
  out a1 * 0dbfs
endin


</CsInstruments>
<CsScore>

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

; Play Instrument #1 for three seconds.
i 1 0 3
e


</CsScore>
</CsoundSynthesizer>


Here is another example of the 0dbfs opcode. It uses the file 0dbfs-1.csd. This example has exactly the same output as the previous example, but output samples should now be normalized between -1 and 1.

Example 23. Example of the 0dbfs opcode with maximum amplitude of 1.

<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
kr = 4410
ksmps = 10
nchnls = 1

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

; Instrument #1.
instr 1
  ; Linearly increase the amplitude value "kamp" from 
  ; -90 to p4 (in dBfs) over the duration defined by p3.
  kamp line -90, p3, p4
  print ampdbfs(p4)
  ; Generate a basic tone using our amplitude value.
a1 oscil ampdbfs(kamp), 440, 1

  ; Since 0dbfs = 1 we don't need to multiply the output
  out a1
endin


</CsInstruments>
<CsScore>

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

; Play Instrument #1 for three seconds.
i 1 0 3 -6
e


</CsScore>
</CsoundSynthesizer>


See also

ampdbfs()

Credits

Author: Richard Dobson
May 2002

New in version 4.10

Example written by Kevin Conder.

Example written by Kevin Conder.

New in version 4.20