Hacker News new | ask | show | jobs
by lock-free 2005 days ago
You're going to have to define "definition" a bit because it's unclear what your goals are.

In general what it sounds like you're talking about is a class of nonlinear processes called "dynamics processing" (common examples are automatic gain correction (AGC), compression, expansion, the compressor-expander (compander)). All have been in production use since the least the 1940s. It's built into your cellphone and also those default sound effects they put in crappy TVs.

Your algorithm as described (convolution with a rect in time == multiplication by sinc in frequency) would be a pretty terrible sounding filter, and would cause some gnarly phasing sound effects to the signal. A linear filter will not solve this problem directly.

What you want to do is extract the envelope of the signal, which can be done using the Hilbert Transform (1), which is an example of a class of algorithms called envelope followers (2).

After extracting the envelope from the signal you can use it to compute a gain to apply to the signal (this is how dynamics processing works). It's not a magic bullet, and dynamics processing is undesirable in high fidelity reproduction. Its used in telephones to compensate for the godawful dynamic range, as an effect in recording or production to add balance within a mix, in conferencing applications to make up for poor mic'ing conditions, and in protection circuitry. You do not want to add more than necesssary, as a general rule.

(1) https://en.wikipedia.org/wiki/Hilbert_transform

(2) https://www.dsprelated.com/showarticle/938.php

1 comments

Dynamics processing is exactly what I was looking for. I wouldn’t have any idea where to look without these replies, so thank you.