Map the Amplitude Envelope from [dbmin,dbmax] to [-inf,dbmax]

I would like to map the envelope of a sound (which has max dB level = dbmax, and min dB level = dbmin) from [dbmin,dbmax] to [-inf,dbmax]. Here is an example : It's like some sort of dynamic compression (or rather dynamic range 'expansion' to be precise), but here the mapping is linear from [dbmin,dbmax] to [-inf,dbmax].

What's the simplest way to do this with an x[n] array? (my input is a soundfile, not an envelope. Is there a simple method for working on envelope (envelope follower ?))

Thank you.

PS : not realtime processing. Thus I can pre-compute dbmax, dbmin.

• It's not quite clear what you mean with "linear" here. If you would like to imply that there is a map dBout = const1 * dBin + const2, then this will not map any finite value to an infinite value. So what are the precise requirements for your map? Oct 23 '13 at 23:32
• I addded a precision in the question : I need to work on sound samples (I don't have envelope yet, do I need an env follower?)
– Basj
Oct 24 '13 at 7:53
• This is still pretty vague. Maybe you should explain what you really want to achieve, i.e. describe the underlying practical problem you want to solve. That would probably make a lot clearer what you really need. Oct 24 '13 at 8:31
• Then I would suggest you use the established techniques for precisely what you want: A noise gate. You essentially don't want to change anything if your level is above the noise floor but only reduce the level if it falls below. You will also want to consider attack, hold and release times. So I think the standard expander model will make you happy. Oct 24 '13 at 12:59
• Sounds like a noise gate, but you don't want to apply a non-linear function to every sample, or it will just result in distortion. You need a change that varies slowly compared to the waveform itself. Jul 21 '14 at 19:01