Classic time-constant coefficient: y += α·(target - y) with α = 1 - exp(-1 / (fs · τ)). Hits ≈63 % of the step in τ seconds.
| 22 | // Classic time-constant coefficient: y += α·(target - y) with |
| 23 | // α = 1 - exp(-1 / (fs · τ)). Hits ≈63 % of the step in τ seconds. |
| 24 | float coeffFromMs(float ms, double sampleRate) noexcept |
| 25 | { |
| 26 | if (ms <= 0.0f) return 1.0f; |
| 27 | const float tau = ms * 0.001f; |
| 28 | return 1.0f - std::exp(-1.0f / static_cast<float>(sampleRate * tau)); |
| 29 | } |
| 30 | |
| 31 | } // namespace |
| 32 |