13.0 Preliminary: Wet/dry mix

13.0 Preliminary: Wet/dry mix#

Audio that has been processed by an effect is called wet, and the unprocessed audio is called dry. A technique common to nearly every effect is to blend the two:

Definition 38 (Wet/dry mix)

Given dry audio \(\mathbf{x}\) and wet audio \(\mathbf{y}\), the wet/dry mix with wet ratio \(w \in [0, 1]\) is

\[(1 - w) \cdot \mathbf{x} + w \cdot \mathbf{y}.\]

A wet ratio of \(w = 0\) outputs the dry signal \(\mathbf{x}\), \(w = 1\) outputs the wet signal \(\mathbf{y}\), and \(0 < w < 1\) blends the two. Since we perceive loudness on a logarithmic scale, the mix is often expressed instead as a wet-to-dry ratio in decibels, comparing the weight of the wet signal to the weight of the dry signal:

\[\text{dB} = 20 \log_{10}\left(\frac{w}{1 - w}\right).\]

Solving for \(w\), we have \(\frac{w}{1 - w} = 10^{\text{dB}/20}\), so

\[w = \frac{10^{\text{dB}/20}}{1 + 10^{\text{dB}/20}} = \frac{1}{1 + 10^{-\text{dB}/20}}.\]

For example, a wet-to-dry ratio of \(0\) dB gives \(w = \frac{1}{2}\): equal parts wet and dry. A ratio of \(6\) dB gives \(w \approx \frac{2}{3}\), weighting the wet signal about twice as heavily as the dry. The code examples in this chapter compute \(w\) with a small helper function, which uses pq.helper.db_to_amplitude to compute \(10^{-\text{dB}/20}\):

def wet_ratio(db: float) -> float:
    """The wet ratio w that mixes the wet signal `db` decibels above the dry signal."""
    return 1 / (1 + pq.helper.db_to_amplitude(-db))