# 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? – Jazzmaniac 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. – Jazzmaniac 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. – Jazzmaniac 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. – endolith Jul 21 '14 at 19:01

## 1 Answer

May be you can try the following:

 dbnew = dbmax * (1 + log((db-dbmin)/(dbmax-dbmin)))


dbnew = -inf when db = dbmin and dbnew = dbmax when db = dbmax. Please let me know if it works.

• thanks. I think it will work (I am going to try). But first of all, how can I work on samples (my input is : a soundfile, and not envelope) ? Do I need an envelope follower ? What's the simpler way for doing this ? – Basj Oct 24 '13 at 7:50
• If you are using Matlab, I believe there is a function for getting the envelope of a signal. What type of signal is it? Is it an AM modulated signal? In that case, you can shift the frequency content to get the envelope. – Vishwanath Oct 24 '13 at 13:10