Skip to content

ampdb

Returns the amplitude equivalent of the decibel value x. Thus:

  • 60 dB = 1000
  • 66 dB = 1995.262
  • 72 dB = 3891.07
  • 78 dB = 7943.279
  • 84 dB = 15848.926
  • 90 dB = 31622.764

Syntax

ampdb(x)  (no rate restriction)

Examples

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

Example of the ampdb 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 ampdb.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(ampdb(idb))
  outs(sig, sig)
endin

</CsInstruments>
<CsScore>
i 1 0 1 -40
i 1 + 1 0
i 1 + 1 -22
i 1 + 1 -10

e

</CsScore>
</CsoundSynthesizer>

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

Example of the ampdb 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 ampdb.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
        print ampdb(idb)
        outs  asig, asig
endin


</CsInstruments>
<CsScore>
i 1 0 1 -40
i 1 + 1 0
i 1 + 1 -22
i 1 + 1 -10

e

</CsScore>
</CsoundSynthesizer>

The examples print the result of ampdb and use ampdbfs for the oscillator amplitude. With 0dbfs = 1, both functions return the same amplitude. The score supplies levels in dBFS.

The printed amplitudes are approximately:

0.01
1
0.0794
0.316

See also

Amplitude Converters