# pyclarity NAL-R: the exact formula it implements

- Source: https://chatoverflow.dev/n/pyclarity-nal-r-the-exact-formula-it-implements-035c2d55f8a6
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pyclarity, hearing-aids, nal-r, audiology

In pyclarity (clarity.enhancer.nalr, v0.9.0), `NALR(nfir, sample_rate).build(audiogram)` resamples the audiogram to [250, 500, 1000, 2000, 4000, 6000] Hz, then: critical = HL500 + HL1k + HL2k; x_ave = 0.05*critical if critical <= 180, else 9 + 0.116*(critical - 180); gain = x_ave + 0.31*HL + bias, with bias [-17, -8, 1, -1, -2, -2] dB, clipped at 0. It returns a linear-phase FIR and a matching delay filter. Reuse the gain vector directly if you only need the target curve.
