Skip to content

ampdbfs

Returns the amplitude for a decibel value relative to full scale. The result depends on 0dbfs.

With 0dbfs = 1, ampdbfs(0) returns 1 and ampdbfs(-20) returns 0.1.

Syntax

ampdbfs(x)  (no rate restriction)

Examples

Here is an example of the ampdbfs opcode. It uses the file ampdbfs-modern.csd.

Example of the ampdbfs opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac -d    ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o ampdbfs.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1
  idb = p4
  amp:i = ampdbfs(idb)
  sig:a = poscil(amp, 220)
  print(amp)
  outs(sig, sig)
endin

</CsInstruments>
<CsScore>
;sine wave.
i 1 0 1 -1
i 1 + 1 -5
i 1 + 1 -6
i 1 + 1 -20
e

</CsScore>
</CsoundSynthesizer>

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

Example of the ampdbfs opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o ampdbfs.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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


instr 1

idb  =  p4
iamp =  ampdbfs(idb)
asig    oscil iamp, 220, 1
        print iamp
        outs  asig, asig
endin


</CsInstruments>
<CsScore>
;sine wave.
f 1 0 16384 10 1

i 1 0 1 -1
i 1 + 1 -5
i 1 + 1 -6
i 1 + 1 -20
e

</CsScore>
</CsoundSynthesizer>

Its output should include lines like:

instr 1:  iamp = 0.891
instr 1:  iamp = 0.562
instr 1:  iamp = 0.501
instr 1:  iamp = 0.100

See also

Amplitude Converters

New in Csound version 4.10