0
$\begingroup$

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 :

enter image description here

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.

$\endgroup$
  • 3
    $\begingroup$ 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? $\endgroup$ – Jazzmaniac Oct 23 '13 at 23:32
  • $\begingroup$ 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?) $\endgroup$ – Basj Oct 24 '13 at 7:53
  • 1
    $\begingroup$ 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. $\endgroup$ – Jazzmaniac Oct 24 '13 at 8:31
  • 1
    $\begingroup$ 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. $\endgroup$ – Jazzmaniac Oct 24 '13 at 12:59
  • 1
    $\begingroup$ 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. $\endgroup$ – endolith Jul 21 '14 at 19:01
1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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 ? $\endgroup$ – Basj Oct 24 '13 at 7:50
  • $\begingroup$ 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. $\endgroup$ – Vishwanath Oct 24 '13 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.