Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@maruaudio/dsp/math/decibels converts decibels to linear amplitude in f64. dbToGain is the ordinary amplitude law, 10^(dB/20); dbToRbjAmplitude is the RBJ Audio EQ Cookbook term A, 10^(dB/40), used by peaking and shelf filters. Both are a single Math.pow call, so their edge behavior is ECMAScript's.

import { dbToGain, dbToRbjAmplitude } from "@maruaudio/dsp/math/decibels"

dbToGain(-6.020599913279624) // 0.5
dbToRbjAmplitude(12.041199826559248) // 2

Functions

NameInputOutputDomain as coded
dbToGaindecibels10 ** (decibels / 20)Any number; −Infinity → 0, +Infinity → +Infinity, NaN → NaN
dbToRbjAmplitudedecibels10 ** (decibels / 40)Same edges as dbToGain
DECIBELS_ALGORITHM_REVISIONconstant1Revision of this conversion law

Lifecycle

None. Stateless functions with no preparation or instance state.

When to use it

Any place a level is set in decibels and applied as a multiplier: a gain control, a trim, a filter's boost or cut. Use dbToRbjAmplitude only for the cookbook's A term, as @maru/filters-biquad does. The reverse direction, gain to decibels, belongs to @maru/mixing-levels (shared behavior).

Limits

  • f64 throughout; there is no Math.fround. Callers that store f32 round the result themselves.
  • No clamp: very large inputs overflow to +Infinity (Number.MAX_VALUE does), and Number.MIN_VALUE returns exactly 1.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by